#include<iostream>
#include<time.h>
using namespace std;
const int N=10000;
int main()
{
int a[N];
time_t start,stop,elapsed;
srand(time(NULL));
for(int i=0;i<N;i++)
{
a[i]=rand();
//cout<<a[i]<<" ";
}
cout<<endl<<endl;
start=clock();
for(int i=N-1;i>0;i--)
{
for(int j=0;j<i;j++)
if(a[j]>a[j+1])
swap(a[j],a[j+1]);
}
stop=clock();
elapsed=stop-start;
cout<<elapsed<<endl;
//for(int i=0;i<N;i++)
//cout<<a[i]<<" ";
cout<<endl;
return 0;
}
#include<time.h>
using namespace std;
const int N=10000;
int main()
{
int a[N];
time_t start,stop,elapsed;
srand(time(NULL));
for(int i=0;i<N;i++)
{
a[i]=rand();
//cout<<a[i]<<" ";
}
cout<<endl<<endl;
start=clock();
for(int i=N-1;i>0;i--)
{
for(int j=0;j<i;j++)
if(a[j]>a[j+1])
swap(a[j],a[j+1]);
}
stop=clock();
elapsed=stop-start;
cout<<elapsed<<endl;
//for(int i=0;i<N;i++)
//cout<<a[i]<<" ";
cout<<endl;
return 0;
}