本帖最后由 EYE_SEE_YOU 于 2013-8-24 09:50 编辑
- public class haha
- {
- public static void main(String[]args)
- {
- int []arr={3,1,6,4,8,2,9,65,1,24,61};
- maopao(arr);
- dayin(arr);
- }
- public static void maopao(int [] arr)
- {
- for (int x=0;x<arr.length-1 ;x++ )
- {
- int temp=0;
- for (int y=0; y<arr.length-x-1;y++ )
- {
- if (arr[temp]<arr[y+1])
- {temp=y+1;
-
- }
- }
- zhihuan(arr,temp,arr.length-x-1);
- }
- }
- public static void dayin(int[]arr)
- {
- for (int x=0;x<arr.length ;x++ )
- {
- System.out.println(arr[x]);
- }
- }
- public static void zhihuan(int[]arr,int x,int y)
- {
- arr[x]=arr[x]^arr[y];
- arr[y]=arr[x]^arr[y];
- arr[x]=arr[x]^arr[y];
- }
- }
复制代码 这算是冒泡排序吧,试试看你们打印的时候会不会出现0 |