(알고리즘) 정렬 (2) - 선택정렬
2020. 2. 23. 20:14
선택 정렬이란? 가장 작은 요소부터 선택해 알맞은 위치로 옮겨서 순서대로 정렬하는 알고리즘 해당 배열에서 가장 작은 값 : 1 1과 6을 스위칭 그다음 작은 값 : 3 4와 3을 스위칭 이와 같은 과정을 반복하면 오름차순으로 정렬이 완료된다. 구현 public class SelectionSort { // static int min = Integer.MAX_VALUE; public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("선택정렬"); System.out.println("요솟수 : "); int nx = sc.nextInt(); int[] x = new int[nx]; for (int ..