#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

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

    for (int i = 0; i < 10; i++)
    {
        int num = rand() % 100; // 生成0~99之间的随机数
        cout << num << ' '; // 使用单引号
    }

    return 0;
}
C++ 生成随机数程序示例:10个0-99随机数

原文地址: https://www.cveoy.top/t/topic/n2zT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录