#include "stdio.h"
#include "math.h"
#include "stdlib.h"
int pd(int k);
int main()
{int x;
printf("Input x:\n");
scanf("%d",&x);
if(x<=1)
printf("Wrong!\n");
else if(pd(x))
printf("x is a zhishu.\n");
else printf("x isn‘t a zhishu.\n");
system("pause");
}
int pd(int k)
{int i;
for(i=2;i<k;i++)
{if((k%i)==0)
return 0;}
return 1;
}
1.不要把;写成了:
2.求开方sqrt()必须是long float/float/double的类型,而x%3==0中的x必须是int
3.函数返回真假也是返回,不可用void.
时间: 2024-11-25 12:55:13