Câu 1:
Program HOC24;
var i.n: integer;
a: array[1..250] of integer;
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
for i:=1 to n do write(a[i],' ');
readln
end.
Câu 2:
Program HOC24;
var i.n: integer;
a: array[1..250] of integer;
t: longint;
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do t:=t+a[i];
write('Tong cac phan tu trong mang la: ',t);
readln
end.
Tham khảo ở đây nhé!!https://sites.google.com/site/thanhtungtran81/home/ky-thuat-lap-trinh/lap-trinh-can-ban-c/tong-cac-phan-tu-trong-mang-1-chieu
Câu 1:
uses crt;
var a:array[1..250]of integer;
i,n:integer;
begin
clrscr;
for i:=1 to 250 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 250 do
write(a[i]:4);
readln;
end.
Câu 2:
uses crt;
var a:array[1..250]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac phan tu trong mang la: ',t);
readln;
end.