标签:ati 语法 交换 bsp [] static main ++ str
package 选择排序; public class 选择排序 { public static void main(String[] args) { int [] arr = {1,3,2,45,65,33,12}; System.out.println("交换之前"); for(int num:arr) System.out.print(num+" "); //核心代码 for(int i = 0; i < arr.length-1; i++) { int k = i; for(int j = k+1; j < arr.length; j++) if(arr[j] < arr[k]) k = j; if(i != k) { int temp = arr[k]; arr[i] = arr[k]; arr[k] = temp; } } System.out.println(); System.out.println("交换后"); for(int num:arr) System.out.print(num+" "); } }
标签:ati 语法 交换 bsp [] static main ++ str
原文地址:https://www.cnblogs.com/JAYPARK/p/10273388.html