Generic Selection Sort Code in C C++ Programming language algorithm C++ program to implement Selection sort using class
#include<iostream.h>
#include<conio.h>
void main( )
{
int a[100],v,max,i,j,k=0;
clrscr( );
cout<<"How Many Values U Want TO Enter : ";
cin>>max;
cout<<"\n\n";
for(i=0;i<max;i++)
{
cout<<"\nEnter A Value : ";
cin>>a[i];
}
for(i=0;i<max;i++)
{
for(j=i+1;j<=max;j++)
{
if(a[i] > a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
cout<<" \n\nThe Sorted List is :";
for(i=0;i<max;i++)
{
cout<<a[i];
}
getche( );
}
#include<iostream.h>
#include<conio.h>
void main( )
{
int a[100],v,max,i,j,k=0;
clrscr( );
cout<<"How Many Values U Want TO Enter : ";
cin>>max;
cout<<"\n\n";
for(i=0;i<max;i++)
{
cout<<"\nEnter A Value : ";
cin>>a[i];
}
for(i=0;i<max;i++)
{
for(j=i+1;j<=max;j++)
{
if(a[i] > a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
cout<<" \n\nThe Sorted List is :";
for(i=0;i<max;i++)
{
cout<<a[i];
}
getche( );
}
0 comments:
Post a Comment