#GESP2405. [GESP]L3-202406-Q2405-J

[GESP]L3-202406-Q2405-J

执行下面 C++ 代码后,输出的结果不可能是 8978189781。

#include <iostream>
#include <cstdlib>  // 为了使用 rand() 和 srand()
#include <ctime>    // 为了使用 time()

using namespace std;

int main() {
    // 设置随机种子
    srand(time(NULL));

    int i = 1;
    int s[5];
    while(i <= 5)
    {
        int a = rand() % 10;

        if(a % 3 == (i + 1) % 3)
            s[i++] = a;
    }
    for(int i = 1; i <= 5; i++)
        cout << s[i];
    cout << endl;
    return 0;
}

{{ select(1) }}

  • 正确
  • 错误