viết chương trình pascal nhập vào từ bàn phím điểm trung bình của 10 học sinh đếm và báo ra màn hình có bao nhiêu học sinh có số điểm trung bình nhỏ hơn 5?
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
Program HOC24;
var i,d: integer;
a: array[1..6] of real;
begin
for i:=1 to 6 do
begin
write('Nhap diem cua ban thu ',i,': '); readln(a[i]);
end;
write('Diem trung binh tren 6.5 la: ');
for i:=1 to 6 do if a[i]>6.5 then write(a[i]:1:1,' ');
writeln;
d:=0;
for i:=1 to 6 do if a[i]<5 then d:=d+1;
write('Co ',d,' ban it hon 5 diem');
readln
end.
uses crt;
var a:array[1..6]of integer;
i,dem:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('Nhap diem cua ban thu ',i,' la: '); readln(a[i]);
end;
for i:=1 to 6 do
if a[i]>6.5 then write(a[i]:4);
writeln;
dem:=0;
for i:=1 to 6 do
if a[i]<5 then inc(dem);
writeln(dem);
readln;
end.
program TinhTBCTimSoNT;
var
ten, lop: string;
n, i, tong, dem: integer;
A: array [1..11] of integer;
trung_binh: real;
function LaSoNguyenTo(x: integer): boolean;
var
i: integer;
begin
if x < 2 then
LaSoNguyenTo := false
else if x = 2 then
LaSoNguyenTo := true
else if x mod 2 = 0 then
LaSoNguyenTo := false
else
begin
i := 3;
while (i <= trunc(sqrt(x))) and (x mod i <> 0) do
i := i + 2;
LaSoNguyenTo := x mod i <> 0;
end;
end;
begin
// Nhập tên và lớp của học sinh
write('Nhập tên của học sinh: ');
readln(ten);
write('Nhập lớp: ');
readln(lop);
// Nhập dãy số nguyên và tính trung bình cộng
repeat
write('Nhập số phần tử của dãy số (n<12): ');
readln(n);
until n < 12;
tong := 0;
for i := 1 to n do
begin
write('Nhập phần tử thứ ', i, ': ');
readln(A[i]);
tong := tong + A[i];
end;
trung_binh := tong / n;
// In tên, lớp, dãy số và trung bình cộng ra màn hình
writeln('Học sinh: ', ten);
writeln('Lớp: ', lop);
write('Dãy số: ');
for i := 1 to n do
write(A[i], ' ');
writeln;
// In các số nguyên tố của dãy số ra màn hình
writeln('Các số nguyên tố của dãy số:');
for i := 1 to n do
if LaSoNguyenTo(A[i]) then
writeln(A[i]);
end.
uses crt;
var st:array[1..10]of string;
a:array[1..10]of integer;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(st[i],a[i]);
for i:=1 to n do
writeln(st[i],' ',a[i]);
readln;
end.
Tham khảo:
program tinh_diem;
uses crt;
var N:array[1..10] of integer;
i,s: integer;
begin
for i:=1 to 10 do
begin
write('nhap diem trung binh cua hoc sinh thu ',i); readln(N[i]);
if N[i]<5 then s:=s+1;
end;
write('so hoc sinh co diem trung binh duoi 5 la: ',s);
readln;
end.