import java.util.Scanner; public class SelectionSort { public static int[] SelectionTest(int[] a){ for(int i = 0;i<a.length-1;i++){ int min = a[i]; int Index = 0; for(int j=i+1;j<a.length;j++){ if(min>a[j]){ min= a[j]; Index= j; } } a[Index]=a[i]; a[i]=min; } return a; } public static void main(String[] args){ Scanner input= new Scanner(System.in); System.out.println("please enter in ..."); int [] array = new int [10]; for(int i = 0;i<array.length;i++){ array[i]=input.nextInt(); } int[] a=SelectionTest(array); for(int i = 0;i<array.length;i++){ System.out.println(array[i]); } } }
慕粉4067798
相关分类