#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
double random(double,double);
srand(unsigned(time(0)));
int a;
FILE *fp;
char ch[10]={0};
fp=fopen("rand1212.txt","a+");
for(int icnt = 0; icnt != 100; ++icnt)
{
a=int(random(10,20));
sprintf(ch,"%d\r\n",a);
fputs(ch,fp);
cout << "No." << icnt+1 << ": " << a<< endl;
}
fclose(fp);
return 0;
}
double random(double start, double end)
{
return start+(end-start)*rand()/(RAND_MAX + 1.0);
}
随机数产生 M-N
最新推荐文章于 2022-09-28 21:13:01 发布