public static void main(String[] args) {
int[] arr = new int[]{1,5,7,1,9,2,4,2,9};
System.out.println(Arrays.toString(arr));
Main.sort(arr);
System.out.println(Arrays.toString(arr));
}
public static void sort(int[] arc){
//需要几趟
for (int i = 0;i < arc.length;i++){
for (int j= 0;j < arc.length -1 -i;j++){
if (arc[j]>arc[j+1]){
int temp = arc[j];
arc[j] = arc[j+1];
arc[j+1] = temp;
}
}
}
}
网友评论