最近开始学C了鸭!!
我真的调试了好一会儿,大家火眼金睛来帮我看一下哪里出错吗?
是算质数的小问题儿
#include<stdio.h>
int main()
{
int total, a, b, count;
count = 3;
printf("大家想算算多少以内的质数呢?:");
scanf("%d", &total);
int num[100000];
int end[100000] = { 2,3 };
for (int i = 4; i <= total; i++)
{
num[i] = i;
for (int n = 0; n <= i; n++)
{
a = num[i] / end[n];
b = num[i] % end[n];
if (b == 0)break;
else
{
if (end[n] >= b)
{
end[count] = num[i];
count += 1;
}
else continue;
}
}
}
for (int i = 0; i <= total; i++)
{
printf("%d ", end[i]);
}
}