Selection Sort

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[10],min;
cout<<"\t\t\tSelection Sort";
cout<<"\nEnter 10 Oderable integers: \n";
for(int i=0;i<10;i++)
cin>>a[i];
for(int i=0;i<10-1;i++)
{
min=i;
for(int j=i+1;j<10;j++)
{
if(a[j]<a[min])
{
min=j;
}
}
if(min!=i)
{
int temp=a[i];
a[i]=a[min];
a[min]=temp;
}
}
cout<<"Shorted List is: ";
for(int i=0;i<10;i++)
cout<<"  "<<a[i];
getch();
return 0;
}
Output:

Popular posts from this blog

Shutdown Pc

Ellipse using OpenGl

String Comparisons