【题目】从键盘上输入任意一个整数,然后判断该数是否为素数 ; 如果是素数则输出"T his is a prime."否则输出"T his is not a prime."输入输入任意一个整数n.输出判断n是否为素数,并输出判断结果:如果n是素数则输出"T his is a prime." 否则输出"T his is not a prime."样例输入3样例输出T his is...
这个是pascal语言写的,你看看 var i,j,k,l:longint;p:boolean;begin readln(l);p:=true;if l=2 then begin writeln('T');end else begin for i:=2 to trunc(sqrt(l)) do begin if l mod i=0 then p:=false;end;if p then writeln('T') else writeln('F');end;end.
int main(int argc,char* argv[]){ int n;bool is=true;cout<<"请输入一个整数:";cin>>n;if(n>1){ for(int i=2;i<n;i++){ if(0==n%i){ is=false;break;} } } else { is=false;} if(is){ cout<<"T"<<endl;} else { cout<<"F"<<endl;} system("PAUSE");retu...