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 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.
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.
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.
uses crt;
var n,i,t,x:integer;
begin
clrscr;
readln(n);
t:=0;
while n>0 do
begin
x:=n mod 10;
if x mod 2=0 then t:=t+x;
n:=n div 10;
end;
writeln(t);
readln;
end.
Var i,n,p:longint;
Begin
Write('Nhap n = ');readln(n);
i:=1;
p:=1;
While i<=n do
Begin
i:=i+1;
p:=p*i;
End;
Write('Tich la ',p);
Readln;
End.
Cách 1 dùng lệnh for do:
Uses crt;
var i,n,k: integer;
begin clrcsr;
readln(n);
for i:=1 to n do begin
if(i mod 2=0) and (i>=10) then k:=k*i;
end;
writeln(k);
readln;
end.
Cách 2 dùng lệnh while do
Uses crt;
var m,n,o: integer;
begin clrcsr;
readln(n);
o:=1;
m:=1;
while (m<n) do begin
m:=m+1;
if(m mod 2=0) and (m>=10) then o:=o*m;
end;
writeln(o);
readln;
end.
uses crt;
var i,n:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
i:=1;
while i<=n do
begin
s:=s*i;
i:=i+1;
end;
writeln(s:0:0);
readln;
end.
1:
a)
uses crt;
var i,n,t:integer;
begin
clrscr;
write('n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+i;
writeln('Tong cac so chan la: ',t);
readln;
end.
b)
uses crt;
var i,t,n:integer;
begin
clrscr;
write('n='); readln(n);
t:=0; i:=1;
while i<=n do
begin
if i mod 2=0 then t:=t+i;
i:=i+1;
end;
writeln('tong cac so chan la: ',t);
readln;
end.
2:
a)
uses crt;
var i,n,t:longint;
begin
clrscr;
write('nhap n='); readln(n);
t:=1;
for i:=1 to n do
if i mod 2=0 then t:=t*i;
writeln('Tich cac so chan la: ',t);
readln;
end.
b)
uses crt;
var i,n,t:longint;
begin
clrscr;
write('n='); readln(n);
t:=1; i:=1;
while i<=n do
begin
if i mod 2=0 then t:=t*i;
i:=i+1;
end;
writeln('Tich cac so chan la: ',t);
readln;
end.