#include
#include
#include
using namespace std;
int main()
{
char *p[5];
char s[64];
int len = 5;
int num = 0;
struct timeval tv;
struct timezone tz;
for (int i = 0;i < len;++i)
{
p[i] = new char[64];
stringstream ss;
//取当前时间
gettimeofday(&tv,&tz);
cout << "秒:" << tv.tv_sec << ",微秒:" << tv.tv_usec << endl;
srand(tv.tv_usec);
num = rand();
//类型转换
ss << num;
ss >> s;
strcpy(p[i],s);
}
for (int i = 0;i < len;++i)
{
cout << "随机数" << i+1 << ":" << p[i] << endl;
delete [] p[i];
}
}
阅读(994) | 评论(0) | 转发(0) |