求助
查看原帖
求助
242026
Linisdjxm楼主2021/7/14 15:22

不知道哪里出了问题, 求助

#include <stdio.h>
#include <math.h>
#include <stdbool.h>
bool ipr(int x)
{
    if(x == 2)
        return true;
    if(x == 1 || x == 4 || x == 0)
        return false;
    double t1 = sqrt(x);
    int count = 2;
    while(count < t1)
    {
        if(x % count == 0)
            return false;
        count++;
    }
    return true;
}

int main(void)
{
    int n;
    scanf("%d",&n);
    int num[n];
    int count = 0;
    while(count < n)
    {
        scanf("%d",&num[count]);
        count++;
    }
    count = 0;
    int pn = 0;
    while(count < n)
    {
        (void)(ipr(num[count])?++pn,(!((bool)(pn - 1))?0:putchar(' ')),printf("%d",num[count]):0);
        count++;
    }
    puts("");
    return 0;
}

2021/7/14 15:22
加载中...