【C++】 生成隨機數

#include <iostream>
#include<stdio.h>
#include<time.h>
#define random(x)(rand()%x)
using namespace std;

int main()
{
    srand((int)time(0));//部署隨機種子
    for (int i = 0; i < 10; i++){
        cout << random(100) << endl;
        //輸出0-100的隨機數
    };
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章