linux 获取随机数函数

来源:互联网 发布:ios软件闪退 编辑:程序博客网 时间:2024/06/12 21:57

--------------------y.cpp---------------------

/* * y.cpp * *  Created on: 2013-12-15 *      Author: root */#include "y.h"unsigned long GetRandomNumber(){    struct timeval tpstart;    gettimeofday(&tpstart, NULL);    srand(tpstart.tv_usec);    unsigned long x = rand();    return x;}

-----------------y.h-------------------------------

/* * y.h * *  Created on: 2013-12-15 *      Author: root */#ifndef Y_H_#define Y_H_#include <iostream>#include <stdio.h>#include <stdlib.h>#include <time.h>#include <sys/time.h>unsigned long GetRandomNumber();#endif /* Y_H_ */



0 0
原创粉丝点击