为什么那个i变量不减1呢??
- import java.util.Arrays;
- public class SelectSort {
- /**
- * 选择排序
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int[] arr={1,2,36,363,56,95,12,32,1232,3263};
- for(int i=0;i<arr.length;i++){
- for(int j=i+1;j<=arr.length-1;j++){
- if(arr[i]>arr[j]){
- int temp=arr[i];
- arr[i]=arr[j];
- arr[j]=temp;
- }
- }
- }
- System.out.println(Arrays.toString(arr));
- }
- }
复制代码 |
|