///////
Search

์„ ํƒ์ •๋ ฌ

ํƒœ๊ทธ
์žฅ์„œ์œค
์•Œ๊ณ ๋ฆฌ์ฆ˜
์ž‘์„ฑ์ผ
2022/09/27

ย ์„ ํƒ์ •๋ ฌ ๋ฌธ์ œ

ํ’€์ด

package com.quiz.selection; import java.util.Arrays; interface Selection { int[] selectionSort(int[] intArray); } class SelectionImpl implements Selection { @Override public int[] selectionSort(int[] intArray) { int getNUm = intArray.length; for (int i = 0; i < getNUm - 1; i++) { int num = i; for (int j = i + 1; j < getNUm; j++) { if (intArray[num] > intArray[j]) { num = j; } } int tmp = intArray[i]; intArray[i] = intArray[num]; intArray[num] = tmp; System.out.println(Arrays.toString(intArray)); } return intArray; } } public class SelectionMain { public static void main(String[] args) { //์ดˆ๊ธฐ ๋ฐฐ์—ด int[] intArray = {7, 3, 2, 8, 9, 4, 6, 1, 5}; int[] result = new SelectionImpl().selectionSort(intArray); } }
Plain Text
๋ณต์‚ฌ
๊ฒฐ๊ณผ
[1, 3, 2, 8, 9, 4, 6, 7, 5] [1, 2, 3, 8, 9, 4, 6, 7, 5] [1, 2, 3, 8, 9, 4, 6, 7, 5] [1, 2, 3, 4, 9, 8, 6, 7, 5] [1, 2, 3, 4, 5, 8, 6, 7, 9] [1, 2, 3, 4, 5, 6, 8, 7, 9] [1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 3, 4, 5, 6, 7, 8, 9]
Plain Text
๋ณต์‚ฌ