第20074题 判断
执行以下C++随机数生成数组并输出的代码后,“结果不可能是89781”的说法是否正确?
#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;
}
A

正确

B

错误