Top Banner
SORTING
59

Selection Sort main( ) { int a[ ] = { 17, 6, 13,12, 2 } ; int i, j, t ; for ( i = 0 ; i

Jan 18, 2018

Download

Documents

Tracy Williams

Bubble Sort main( ) { int a[ ] = { 17, 6, 13, 12, 2 } ; int i, j, t ; for ( j = 0 ; j <= 3 ; j++ ) { for ( i = 0 ; i <= 3 ; i++ ) { if ( a[ i ] > a[ i + 1 ] ) { t =a[ i ] ; a[ i ] = a[ i + 1 ] ; a[ i + 1 ] = t ; } } } for ( i = 0 ; i <= 4 ; i++ ) printf ( ”%d”, a[ i ] ) ; } - j i i
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

Selection Sort main( ) { int a[ ] = { 17, 6, 13,12, 2 } ; int i, j, t ; for ( i = 0 ; i