#include<iostream>
#include<time.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 10
using namespace std;
class StopWatch
{
public:
StopWatch()
{
startTime=time(NULL);
}
void start()
{
startTime=time(NULL);
}
void end()
{
endTime=time(NULL);
}
clock_t getStartTime()
{
return startTime;
}
clock_t getEndTime()
{
return endTime;
}
double getelapseTime()
{
return (double)(getEndTime()-getStartTime())/1000;
}
private:
clock_t startTime;
clock_t endTime;
};
int main()
{
int a[MAX];
int d,i,j,t,m=10;
//srand((unsigned)time(NULL));
//for(i=0;i<MAX;++i)
//a[i]=rand()%MAX;
StopWatch sw;
sw.start();
for(i=0;i<MAX;i++)
{
a[i]=m;
m--;
cout<<a[i]<<endl;
}
for(i=0;i<MAX;++i)
{
d=i;
for(j=i+1;j<MAX;++j)
if(a[j]<a[d])
d=j;
if(d!=i)
{
t=a[d];a[d]=a[i];a[i]=t;
}
}
sw.end();
double elapsetime=sw.getelapseTime();
cout<<"Spend time is"<<elapsetime<<endl;
return 0;
}