#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
FILE *f;
time_t t;
time(&t);
srand(t);
f = fopen("C:\\a.txt", "wt");
if(f)
{
for(int i=0; i<30; i++)
{
for(int j=0; j<3; j++)
{
fprintf(f, "%d\t", rand()%200 + 1);
}
fprintf(f, "\n");
}
fclose(f);
}
return 0;
}
#include <fstream.h>
#include <iostream>
{int i=0;
int k=0;
srand((unsigned)time( NULL ));
ofstream ofs("abc.txt");
for(int j=1;j<=90;j++)
{
k=rand()%200+1;
ofs<<'\t'<<k;
if(j%3==0)
{
printf("\n");
ofs<<endl;//三个数换行
}
}
ofs.close();
}
{
CFile ReadFile("C:\\abc.txt", CFile::modeRead);
char * pRead = NULL;
int changdu;
changdu = ReadFile.GetLength();
pRead = new char[changdu + 1];
pRead[changdu] = 0;
ReadFile.Read(pRead, changdu);
ReadFile.Close();
//delete pBuf;
//pBuf = NULL;
MessageBox(pRead);
}
生成1~200间的90个随机数
最新推荐文章于 2023-09-17 14:47:50 发布