郁闷,不知道哪里出错了,输入个俩位数输出了一个4位数- -!
# include <stdio.h>
void main()
{
int n,i=2;
scanf("%d",n);
if(n%i!=0)i++;
else printf("%d is not a sushu\n",n);
while(i>=n)
printf("%d is a sushu\n",n);
}
郁闷,不知道哪里出错了,输入个俩位数输出了一个4位数- -!
# include <stdio.h>
void main()
{
int n,i=2;
scanf("%d",n);
if(n%i!=0)i++;
else printf("%d is not a sushu\n",n);
while(i>=n)
printf("%d is a sushu\n",n);
}
//方法不对, 素数是只能被1和他本身整除的数.
//所以应该判断这个数是不是能被其他数整除.
//你的程序中if(n%i!=0)i++; 只执行了一次.
//修改了下,你看看
# include <stdio.h>
void main()
{
int n,i=2;
scanf("%d", &n ); //输入缺少取地址符&
for(i; i < n; i++ )
if(n % i == 0)
break;
if(i >= n)
printf("%d is a sushu\n",n);
else
printf("%d is not a sushu\n",n);
}