#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void Selection(int a[],int n);
void main()
{
clrscr();
int arr[100],i,n;
cout<<"\nHOW MANY NUMBER's YOU HAVE ?\n ";
cin>>n;
cout<<"\nENTER "<<n<<" NUMBERS :\n ";
for(i=0;i<n;i++)
{
cin>>arr[i];
cout<<" ";
}
Selection(arr,n);
cout<<"\n\nPress any Key..";
getch();
}
void Selection(int temp[],int p)
{
int q,small;
for(int i=0;i<p;i++)
{
small=temp[i];
q=i;
for(int j=i+1;j<p;j++)
{
if(temp[j]<small)
{
small=temp[j];
q=j;
}
}
temp[q]=temp[i];
temp[i]=small;
}
cout<<"\nTHE SORTED NUMBERS USING SELECTION SORT \n";
for(i=0;i<p;i++)
{
cout<<" "<<temp[i];
}
}
#include<stdio.h>
#include<conio.h>
void Selection(int a[],int n);
void main()
{
clrscr();
int arr[100],i,n;
cout<<"\nHOW MANY NUMBER's YOU HAVE ?\n ";
cin>>n;
cout<<"\nENTER "<<n<<" NUMBERS :\n ";
for(i=0;i<n;i++)
{
cin>>arr[i];
cout<<" ";
}
Selection(arr,n);
cout<<"\n\nPress any Key..";
getch();
}
void Selection(int temp[],int p)
{
int q,small;
for(int i=0;i<p;i++)
{
small=temp[i];
q=i;
for(int j=i+1;j<p;j++)
{
if(temp[j]<small)
{
small=temp[j];
q=j;
}
}
temp[q]=temp[i];
temp[i]=small;
}
cout<<"\nTHE SORTED NUMBERS USING SELECTION SORT \n";
for(i=0;i<p;i++)
{
cout<<" "<<temp[i];
}
}