素数的判定
输入一个数,判断是不是素数。#include<stdio.h>
#include<math.h>
main()
{
int a,b,c;
scanf("%d",&a);
{
for(b=2;b<=sqrt(a);b++)
c=a%b;
}
if(c==0) printf("此数为合数");
if(c!=0) printf("此数为素数");
}
有很多明显是合数的,它也判定为素数,请各位大师帮忙看下,该怎么修改?
2017-04-24 16:07


2017-04-24 16:57



2017-04-24 17:00