用PASCAL编程:1至100的素数
会的写出来,不会的别说废话!
参考答案:Program xxx(input,output);
var
n,i:integer;
f:boolean;
begin
for n:=1 to 100 do
begin
f:=true;
for i:=2 to trunc(sqrt(n)) do
if (n mod i =0) then begin f:=false;break;end;
if f then writeln(n:4);
end;
end.
会的写出来,不会的别说废话!
参考答案:Program xxx(input,output);
var
n,i:integer;
f:boolean;
begin
for n:=1 to 100 do
begin
f:=true;
for i:=2 to trunc(sqrt(n)) do
if (n mod i =0) then begin f:=false;break;end;
if f then writeln(n:4);
end;
end.