Viết chương trình và tích số N đầu tiên và sử dụng biến mảng
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.
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.
a) Var X : Array [1;50] of integer; (sai cách khai báo mảng)
-> Var X : Array [1..50] of integer;
b) Var X : Array [5..50.5] of real; (sai vì chỉ số là số thực)
-> Var X : Array [5..50] of real;
c) For i: 1,5 to 10 do write ('A'); (sai vì giá trị đầu là số thực)
-> For i: 1,5 to 10 do write ('A');
d) For i: 1 to ; 10 do write ('A'); (sai vì sau to có dấu ; và sau i: thiếu dấu =)
->For i:= 1 to 10 do write ('A')
e) While x:=10 do x:=x+5; (điều kiện sai, đây là phép gán không phải điều kiện)
-> While x=10 do x:=x+5;
uses crt;
var a:array[1..50]of longint;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
writeln(t);
readln;
end.
tham khảo: