为什么过不了啊,求大神指教

P5737 【深基7.例3】闰年展示

yz123127054 @ 2023-05-09 22:56:40


#include<iostream>
#include<math.h>

using namespace std;

bool isprime(int x)
{
    if (x <= 1)
    {
        return false; 
    }
    for (int i = 2; i <= sqrt(x) ; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(){
    int n, flag;
    cin >> n;
    int num[n];
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (isprime(num[i]))
        {
            // flag = 1;
            cout << num[i] << " ";
            // if (flag == 1)
            // {
            //     cout << " ";
            //     flag = 0;
            // }

        }
    }
}

by wangkeli @ 2023-05-10 00:33:53

为什么你会产生一丝这份代码能过的感觉。


by iterator_traits @ 2023-05-10 07:44:30

@yz123127054 会不会是交错题了


by zsjaaaxyzgfwpl1314 @ 2023-05-15 17:48:27

???


by blue_gandi_ @ 2023-07-13 19:53:30

交错题了吧?


|