- /**
- 给int数组进行冒泡排序
- @param arr 接收一个int类型的数组
- */
- public static void selectSort(int[] arr)
- {
- for(int x=0;x<arr.length;x++)
- {
- for(int y=0;y<arr.length-x-1;y++)
- {
- if(arr[y]>arr[y+1])
- {
- swap(arr,y,y+1);
- }
- }
- }
- }
- /**
- 给数组中元素进行位置转换
- @param arr 接收一个int类型的数组
- @param a 要置换的位置
- @param b 要置换的位置
- */
- private static void swap(int[] arr,int a,int b)
- {
- int temp=arr[a];
- arr[a]=arr[b];
- arr[b]=temp;
- }
- //该片段来自于http://www.codesnippet.cn/detail/1112201411239.html
来源: http://www.codesnippet.cn/detail/1112201411239.html