题库 C++/C语言题库 题目列表 执行下面C++代码后,输出的结果不可能是89781。( )1...
判断题

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

1 #include <iostream>
2 #include <cstdlib> // 为了使用 rand() 和 srand()
3 #include <ctime> // 为了使用 time()
4
5 using namespace std;
6
7 int main() {
8  // 设置随机种子
9  srand(time(NULL));
10
11  int i = 1;
12  int s[5];
13  while(i <= 5)
14  {
15   int a = rand() % 10;
16   if(a % 3 == (i + 1) % 3)
17    s[i++] = a;
18  }
19  for(int i = 1; i <= 5; i++)
20   cout << s[i];
21  cout << endl;
22  return 0;
23 }
A.
正确
B.
错误
题目信息
C++语言等级考试真题 2024年 三级 判断题
100%
正确率
0
评论
53
点击