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.
uses crt;
var a:array[1..100]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(t);
readln;
end.
Var a:array[1..15] of integer;
i,s:integer;
Begin
I:=1;
While i<=15 do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
i:=i+1;
End;
Write('Tong la ',s);
Readln;
End.
program TongN;
var
n, i, tong: integer;
begin
tong := 0;
writeln('Nhap so nguyen duong N: ');
readln(n);
i := 0;
while i < n do
begin
i := i + 1;
tong := tong + i;
end;
writeln('Tong cac so tu 1 den ', n, ' la ', tong);
readln;
end.
program TinhTongTich;
var
N, i, Tong, Tich:integer;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
i:=1;
Tong:=0;
Tich:=1;
while i<=N do
begin
Tong:=Tong+i;
Tich:=Tich*i;
i:=i+1;
end;
writeln('Tong cac so tu 1 den ', N, ' la: ', Tong);
writeln('Tich cac so tu 1 den ', N, ' la: ', Tich);
readln;
end.
uses crt;
var n,i,t1,t2:integer;
begin
clrscr;
t1:=0;
t2:=0;
repeat
readln(n);
if n mod 2=0 then t1:=t1+n
else t2:=t2+n;
until n=0;
writeln(t1,' ',t2);
readln;
end.
program tinhtongtubanphim;
var i,s : real; kt:boolean;
begin
s:=0;
kt:=true;
while kt=true do
begin
write("nhap so tu ban phim: ");
readln(i);
s:=s+i;
if i:=0 then kt:=false;
end;
writeln('Tong = ',s);
readln;
end.
Lời giải:
program hotrotinhoc;
var n: integer;
t: longint;
begin
write('Nhap so :'); readln(n);
t:=n;
while n<>0 do
Begin
write('Nhap so:'); readln(n);
t:=t+n;
end;
write(t);
readln
end.