求第n个纯粹合数。求大佬指教我哪里有错
#include <stdio.h>#include <math.h>
int isnum(int n)
{
int i;
if(n==0) return 1;
if(n==1||n==2||n==3) return 0;
for(i = 2; i <= sqrt(n); i++)
if(n%i == 0)
return 1;
return 0;
}
int main()
{
int n, i, j, p, q;
int a[100]={0};
while(scanf("%d", &n)==1)
{
for(i = 1, j = 100; i <= 100; j++)
{
p = j%100;
q = p%10;
if(isnum(j)&& isnum(p) && isnum(q))
{
a[i] = j;
i++;
}
}
printf("%d\n", a[n]);
}
return 0;
}
[此贴子已经被作者于2016-12-19 15:09编辑过]