首页 > 其他 > 详细

srand+rand() combination

时间:2020-01-30 16:08:44      阅读:57      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <cstdlib> /* include to allow rand() to be used */
#include<ctime>/*just used in function: time(NULL)*/
using namespace std;
int main()
{
 int x; /* variable to hold our random integer */
 srand(time(NULL));//system‘s time, in seconds,if not, the value will not change
 x = rand();
 cout << "x = " << x << endl;
 x = rand();
 cout << "x = " << x << endl;
 return 0;
} 

 

srand+rand() combination

原文:https://www.cnblogs.com/defoliate/p/12242879.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!