- class Demo_ArrayList
- {
- public static void main(String[] args)
- {
- int [] arr = {81,72,63,44,55,46,37,88}; //9
- int temp;
- for (int x = 0; x < arr.length ;x++ )
- {
- int max = 0;
- for (int y = 1; y < (arr.length-x) ; y++ )
- {
- if(arr[y] > arr[max])
- {
- max = y;
- System.out.println(max);
- }
-
- /*
- temp = arr [arr.length-x-1];
- arr[arr.length-x-1] = arr [max];
- arr[max] = temp;
- */
- }
- temp = arr [arr.length-x-1];
- arr[arr.length-x-1] = arr [max];
- arr[max] = temp;
-
- }
- for (int x = 0 ; x < arr.length ; x ++)
- {
- System.out.print(arr[x]+ " ");
- }
- }
- }
复制代码 求指点。
|
|