标签:sqrt 质数 turn 函数 math can scan bsp put
#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.
标签:sqrt 质数 turn 函数 math can scan bsp put
原文地址:http://www.cnblogs.com/cxr1234/p/6128658.html