2 câu trả lời
Cách 1 +) for...do
program hotrotinhoc ;
var i,n,tich : integer ;
begin
write('n='); readln(n);
tich:=1;
for i:=1 to n do
if i mod 2=0 then tich:=tich*i;
write('Tich la:',tich);
readln
end.
Cách 2 +) while...do
program hotrotinhoc ;
var n,tich : integer ;
begin
write('n='); readln(n);
tich:=1; i:=0;
while i<=n do
begin
i:=i+2;
tich:=tich*i;
end;
write('Tich la :',tich);
readln
end.
program tich;
Uses crt;
Var
n,dem,so:integer; P:longword;
Begin
Clrscr;
write('Nhap n: '); readln(n);
Dem:=0; so:=0; P:=1;
while dem<n do
Begin
so:=so+2; dem:=dem+1; P:=P*so;
End;
write('Tich N so chan: ',P);
Readln;
End.
#HN
#Study_well!
Câu hỏi trong lớp
Xem thêm