// Program for Bubble Sort
#include <iostream.h>
#include <conio.h>
//----------------------------------------------------------------------
void Bubblesort ( int array[] , int UB )
{
for ( int i = 0 ; i <= UB ; i++ )
for ( int j=0 ; j<=UB-1 ; j++ )
{
if ( array [j] > array [j+1] )
{
int temp = array [j] ;
array [j] = array[j+1] ;
array [j+1] = 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 };
Bubblesort ( 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