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.
while..do
Program HOC24;
uses crt;
var i,n: integer;
S: longint;
begin
clrscr;
write('Nhap N: '); readln(n);
i:=0; s:=0;
while i<n do
begin
i:=i+1;
s:=s+i*(i+1);
end;
write('S=',S);
readln
end.
Câu 1:
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(s);
readln;
end.
Câu 2:
uses crt;
var t,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
t:=t+i;
writeln(t);
readln;
end.
uses crt;
var x,n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
begin
readln(x);
if x mod 2=0 then t:=t+x;
end;
writeln(t);
readln;
end.
program ideone;
var i,n,x,res:longint;
begin
readln(n);
res:=0;
for i:=1 to n do
begin
read(x);
if x mod 2 = 0 then
res:=res+x;
end;
write(res);
end.
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
if a[i] mod 2<>0 then t:=t+a[i];
writeln(t);
readln;
end.
1:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
t:=t+i*i;
write(t);
readln;
end.
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.
uses crt;
var i,j,m:integer;
t:longint;
a:array[1..100,1..100]of integer;
begin
clrscr;
write('nhap m:');readln(m);
for i:=1 to m do
for j:=1 to m do
begin
write('a[',i,',',j,']=');readln(a[i,j]);
end;
clrscr;
writeln('ma tran da nhap la:');
for i:=1 to m do
begin
for j:=1 to m do
write(a[i,j]:5);writeln;
end;
i:=1;j:=1;
while i<=m do
begin
t:=t+a[i,j];
inc(i);inc(j);
end;
writeln('tong cac phan tu nam tren duong cheo chinh la: ',t);
readln;
end.
program Tinhtong;
uses crt;
var a:array[1..100] of integer;
sum,n:integer;
begin clrscr;
write('Nhap n = '); readln(n);
for i:=1 to n do
begin
write('a[',i,'] = '); readln(a[i]);
end;
sum:=0;
for i:=1 to n do
if (a[i] mod 2 = 0) then sum:=sum+a[i];
write('Tong cac so chan = ',sum);
readln;
end.
Program HOC24;
var d,N,i: integer;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0; d:=0;
for i:=1 to n do
begin
t:=t+a[i];
if a[i]>0 then d:=d+1;
end;
writeln('Tong day so la: ',t);
write('Co ',d,' so nguyen duong');
readln
end.
program TinhTong;
uses crt;
var
N, i, j, tich: integer;
S: real;
begin
clrscr;
write('Nhap so nguyen N: ');
readln(N);
S := 0;
tich := 1;
for i := 1 to N do
begin
tich := tich * i;
S := S + tich;
end;
writeln('Tong S = ', S:0:2);
readln;
end.
tôi chạy nó ra thế này bạn ơi