[备忘]一个二维数组的冒泡排序
对二维数组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;
}
}
{
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;
}
}
posted on 2006-11-23 23:03 wqlblogger 阅读(888) 评论(2) 编辑 收藏 举报