C++产生随机数的方法三:调用系统时间,系统时钟(程序不太确定)

调用系统时间

#include <iostream>
#include <windows.h>
using namespace std;
int rand_number()
{
    SYSTEMTIME sys;
    GetLocalTime(&sys);
    return sys.wMilliseconds;
}
int main()
{
  cout<<rand_number()<<endl;//输出的是毫秒数,随机数产生的时间间隔是毫秒级
  return 0;
}

调用系统时钟


猜你喜欢

转载自blog.csdn.net/qq_43312665/article/details/87969365
今日推荐