#include <stdio.h> #include <iostream> #include <time.h> using namespace std; #define MAX 100 int main(int argc, char* argv[]) { srand( (unsigned)time( NULL ) ); //srand()函数产生一个以当前时间开始的随机种子 for (int i=0;i<10;i++) cout<<rand()%MAX<<endl; //MAX为最大值,其随机域为0~MAX-1 return 0; }
产生随机数
最新推荐文章于 2024-02-18 22:59:30 发布