随机数生成器,完成后打开文件。

#include<iostream>
#include<time.h>
#include<cstdio>
#include<stdlib.h>
using namespace std;
int main()
{
    freopen("rand.txt","w",stdout);
    long long a,b,n,cou;//cou:数据个数; 
    cin>>a>>b>>cou;
    srand(time(NULL));
    for(long long i=1;i<=cou;i++)
    {
        n=rand()%(b-a+1)+a;
        cout<<n<<' ';
    }
    fclose(stdout);
    system("rand.txt");
}

 

posted on 2015-11-01 13:05  tjtzgby  阅读(168)  评论(0编辑  收藏  举报

导航