dengch

 

c++中生成随机数

#include<iostream>
#include<string>
#include<algorithm>
#include<ctime>
using namespace std;
const int INF = 1e9;

int main() {
  
    //设置种子
    srand((unsigned)time(NULL));
    //可随机生成0-10以内的数
	int t = rand() % 10;
	cout << t << endl;
}

posted on 2023-09-20 12:25  BkDench  阅读(50)  评论(0)    收藏  举报

导航