执行以下C++随机数生成数组并输出的代码后,“结果不可能是89781”的说法是否正确?

cr037474 判断题 共 个子题
#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

错误

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧