用pascal语言求100以内的质数program oo;vari,j:integer;f:boolean;beginfor i:=1 to 100 dobeginf:=true;for j:=2 to trunc(sqrt(i))+1 doif i mod j=0 then begin f:=false;end;if f=true thenwrite(i:4);end;readln;end.for j:=2 to trunc(sqrt(i))+1 do截

来源:学生作业帮助网 编辑:作业帮 时间:2024/08/07 15:32:07
用pascal语言求100以内的质数program oo;vari,j:integer;f:boolean;beginfor i:=1 to 100 dobeginf:=true;for j:=2 to trunc(sqrt(i))+1 doif i mod j=0 then begin f:=false;end;if f=true thenwrite(i:4);end;readln;end.for j:=2 to trunc(sqrt(i))+1 do截
xr@_e)x|P6&qzK-T"mPd!Ud-(^ehNjyu¾~vQ"f7xyv ;`sri0 j(iCR0kZ$+2L+I=*sJ!Yڏ"7bFkvq>nTQՄ2]1GQ!"g_zZv:00 DR5/޻8CD*N[&8)å9co4G;xŜ߿8|<ƒk$3DoĢ{̛30ԯzgU\{gS:0j,dy}۟/Ÿױ7%|8Zw< %>F$V\7_يs^ϭ|mKZd3ޣ VTr~>YL­QgLHt}OJ%

用pascal语言求100以内的质数program oo;vari,j:integer;f:boolean;beginfor i:=1 to 100 dobeginf:=true;for j:=2 to trunc(sqrt(i))+1 doif i mod j=0 then begin f:=false;end;if f=true thenwrite(i:4);end;readln;end.for j:=2 to trunc(sqrt(i))+1 do截
用pascal语言求100以内的质数
program oo;
var
i,j:integer;
f:boolean;
begin
for i:=1 to 100 do
begin
f:=true;
for j:=2 to trunc(sqrt(i))+1 do
if i mod j=0 then begin f:=false;end;
if f=true then
write(i:4);
end;
readln;
end.
for j:=2 to trunc(sqrt(i))+1 do
截尾函数后为什么要加1?

用pascal语言求100以内的质数program oo;vari,j:integer;f:boolean;beginfor i:=1 to 100 dobeginf:=true;for j:=2 to trunc(sqrt(i))+1 doif i mod j=0 then begin f:=false;end;if f=true thenwrite(i:4);end;readln;end.for j:=2 to trunc(sqrt(i))+1 do截
其实加与不加一个样子
不信你可以试验一下
但是我建议的是不加
因为很多大的程序要对数字判奇偶
上万个数字判断
如果每个数字都要多加一次判断
没用
而且还浪费时间
这是我的看法
如果有不同的
绝不否认!