[备忘]一个二维数组的冒泡排序

对二维数组Map的第二列进行排序

int  Map[ 100 ][ 2 ];

 

void  BubbleSort( int  low, int  high)
{
    
int i,j,ii;
    
int exchange; 
    
int Temp ;

    
for(i = low;i <= high;i++)
    

        exchange 
= 0
        
for(j = high-1;j>=i;j--
        
{
            
if(map[j+1][1< map[j][1])
            
{
                Temp 
= map[j+1][1]; 
                map[j
+1][1= map[j][1];
                map[j][
1= Temp;

                Temp 
= map[j+1][0]; 
                map[j
+1][0= map[j][0];
                map[j][
0= Temp;
                exchange 
= 1;
            }

        }

        
if(!exchange) 
            
return;
    }

}


你可能感兴趣的:(冒泡排序)