用PASCAL编的循环结构程序

2025-01-18 11:59:39
推荐回答(1个)
回答1:

1.var n,i,tmp:integer;ans,ans2:int64;
begin
readln(n);
ans:=1;
for i:=1 to n do
begin
read(tmp);
ans:=ans*tmp;
ans2:=ans2+tmp*tmp;
end;
writeln(ans);writeln(ans2);
end.

2.
var i,tmp:integer;zheng,fu,zero:integer;
begin
for i:=1 to 20 do
begin
readln(tmp);
if tmp>0 then inc(zheng)
else if tmp=0 then inc(zero)
else if tmp<0 then inc(fu);
end;
writeln(zheng,' ',fu,' ',zero);
end.