BubbleSort(C)
void BubbleSort( int * Array,int length ) { assert( Array != NULL && length>0 ); bool bNoswap = false; int i = length-1; int j = 0; int tempswap = 0; for ( ;i>0;i-- ) { bNoswap = true; for ( j=0;j<i;j++ ) { if ( Array[j]>Array[j+1] ) { bNoswap = false; tempswap = Array[j]; Array[j] = Array[j+1]; Array[j+1] = tempswap; } } if ( bNoswap == true ) { return; } } }

浙公网安备 33010602011771号