pascal输入一个自然数,判断这个自然数是不是素数.
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/31 16:55:46
看vari,j,n,t:longint;a:array[1..1000]oflongint;beginwhilenoteolndobegininc(n);read(a[n]);end;i:=1;j:=
前面写错了,不好意思
已全部补充完整,请查收1varn,i,s:int64;beginreadln(n);i:=2;s:=0;whilei100000thenbreak;end;ifs>100000thencontinue
varn:longint;beginreadln(n);ifnmod7=0thenwriteln('yes'){除以7取余,是否等于0,等于则输出yes,否则输出no}elsewriteln('no'
var a:array[1..5,1..5] of integer; i,j,max,ij,x,y:integer;begi
这个其实可以用多种方法实现方法1:分离数字法varx,l,s:longint;beginread(x);whilex>0dobeginl:=xmod10;inc(s,l);x:=xdiv10;//当前
vari,x,a:integer;beginread(x);a:=0;fori:=1toxdobeginifxmodi=0thena:=a+i;end;write(a);end.
programyueshuhe;varn,i,s:longint;beginwriteln('inputn:');readln(n);s:=1;fori:=2tondobeginifnmodi=0th
只能告诉你算法,pascla不会定义一个变量sum,记录约数之和得到自然数a,定义变量i从1遍历到a,只要a/i==0,sum=sum+i,最后输出sum就是了
公约数公倍数vara,b,i,p,n,m:longint;beginread(a,b);ifa>bthenp:=aelsep:=b;whilei
varn,s:longint;beginread(n);s:=0;whilen0dobegins:=s+nmod10;n:=ndiv10;end;writeln(s);end.自创!
vartop,j,n,m:integer;s:array[0..100]ofinteger;procedureprint;vari:integer;beginifs[1]nthenwrite(n,'=
programj;vara,b,c,m,n:integer;beginreadln(m);a:=mdiv100;b:=(mdiv10)mod10;c:=mmod10;n:=c*100+b*10+a;w
varn:longint;beginreadln(n);writeln(abs(n));{绝对值}writeln(sqr(n));{平方}writeln(sqrt(n));{平方根}writeln(p
vari,j,n:longint;z:boolean;beginreadln(n);writeln(2);fori:=3tondobeginz:=true;forj:=2toi-1doifimodj=
vara,b,s,n:longint;begins:=0;b:=0;whiles10dobegininc(b);forn:=1tobdoifbmodn=0thens:=s+1;end;writeln(
varn,i,j,k:integer;beginreadln(n);fori:=1tondobeginforj:=1to3dobeginwrite('':n-i+1);fork:=1toi+i-1do
typeintar=array[1..20,1..20] of shortint;boolar=array[1..20,1..20] of boolean;va
programex1;varj,m,n,m1,n1,a,b:integer;beginreadln(m,n);ifm再问:拜托,错了再答:programex1;varj,m,n,m1,n1,a,b:i
vars,n,a:longint;begins:=0;whilea0dobeginn:=amod10;s:=s+n;a:=adiv10;end;writeln(s);end.