- package com.yuxi.day0923;
- import java.util.ArrayList;
- import java.util.Collections;
- public class Test2 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- int[][] arr = { { 22, 4325, 534 }, { 35, 525, 536 },{342,564,646} };
- ArrayList<Integer> al = new ArrayList<Integer>();
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- al.add(arr[i][j]);
- }
- }
- Collections.sort(al);
- int num = al.size()-1;
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- arr[i][j] = al.get(num--);
- }
- }
- for(int i=0;i<arr.length;i++)
- {
- for(int j=0;j<arr[i].length;j++)
- {
- System.out.print(arr[i][j]+"\t");
- }
- System.out.println();
- }
- }
- }
复制代码
|
|