#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; }
原文地址:https://www.cnblogs.com/defoliate/p/12242879.html
时间: 2024-10-20 06:58:53