1 回答
TA贡献4条经验 获得超1个赞
public static void main(String args[]){
int a[][] = {{4, 1}, {1, 2}, {2, 3}, {2, 1}, {3, 2}, {3, 1}, {1, 1}};
for (int i = 0; i < a.length; i++){
for (int j = i; j < a.length;j++){
if (a[i][0] > a[j][0] | | (a[i][0] == a[j][0] & & a[i][1] > a[j][1])){
int temp = a[i][0];
a[i][0] = a[j][0];
a[j][0] = temp;
temp = a[i][1];
a[i][1] = a[j][1];
a[j][1] = temp;
}
}
}
for (int i = 0;i < a.length;i++){
System.out.println(a[i][0] + "," + a[i][1]);
}
}
添加回答
举报