码迷,mamicode.com
首页 > 其他好文 > 详细

srand+rand() combination

时间:2020-01-30 15:49:00      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:null   seconds   pac   fun   include   color   function   second   std   

#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

标签:null   seconds   pac   fun   include   color   function   second   std   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!