// Program for Selection Sort
#include <iostream.h>
#include <conio.h>
//----------------------------------------------------------------------
void Selectionsort ( int array[] , int UB )
{
for ( int i = 0 ; i <= UB ; i++ )
for ( int j=i+1 ; j<=UB ; j++ )
{
if ( array [i] > array [j] )
{
int temp = array [i] ;
array [i] = array[j] ;
array [j] = temp ;
}
}
}
void Showarray ( int array[] , int UB )
{
gotoxy ( 1,2 ) ;
cout << "\n" ;
for ( int i = 0 ; i <= UB ; i++ )
{
cout << array [i] << endl ;
}
}
//----------------------------------------------------------------------
void main ()
{
clrscr ();
int array [10] = { 42 , 23 , 74 , 11 , 65 , 58 , 94 , 36 , 99 , 87 };
Selectionsort ( array , 9 ) ;
Showarray ( array , 9 ) ;
getch ();
}
"I have not failed. I've just found 10,000 ways that won't work."
--Thomas Edison
"Not everything that can be counted counts, and not everything that counts can be counted."
--Albert Einstein
"If you can't make it good, at least make it look good."
"Your most unhappy customers are your greatest source of learning."
--Bill Gates
No comments:
Post a Comment