21 lines
402 B
C++
21 lines
402 B
C++
|
#include <iostream>
|
||
|
#include <cstdlib>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
srand(time(NULL));
|
||
|
|
||
|
int arr[5];
|
||
|
int i = 0;
|
||
|
// 生成 5 个随机数并输出
|
||
|
while (i < 5)
|
||
|
{
|
||
|
arr[i] = rand() % 100; // 生成 0~99 之间的随机数: max = 99, min = 0 -> rand() % (max - min + 1) + min
|
||
|
cout << "arr[" << i << "] = " << arr[i] << endl;
|
||
|
i++;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|