#include<iostream>
#include <fstream>
#include <vector>
#include<algorithm>
#include <ctime>
using namespace std;
int main()
{
clock_t start,finish;
double totaltime;
ofstream outmyfile("c:\da.txt");
srand(time(NULL));
for (int i=0;i<100000;i++)
{
outmyfile<<rand()%1000000<<" ";
}
outmyfile.close();
ifstream myfile("c:\da.txt");
vector<int>data;
if (!myfile)
{
cout<<"file open error!"<<endl;
exit(1);
}
int tmp;
while (!myfile.eof())
{
myfile>>tmp;
data.push_back(tmp);
}
myfile.close();
start=clock();
sort(data.begin(),data.end());
finish=clock();
totaltime=finish-start;
cout<<totaltime<<endl;
ofstream outfile("c:\dt.txt");
if (!outfile)
{
cout<<"file write error"<<endl;
exit(1);
}
for ( i=0;i<data.size();i++)
{
outfile<<data[i]<<" ";
}
return 0;
}