Notice
Recent Posts
Recent Comments
Link
삐까냥의 파도타기
선택 정렬 본문
public class SortSelection {
public static void main(String[] agr){ int[] array = {5,7,8,4,6,9,2,3,1};
//선택 for ( int i = 0; i < array.length - 1; i++ ) { int min = i; for ( int j = i+1; j < array.length; j++ ) { if ( array[min] > array[j] ){ min = j; } }
if ( i != min ) { int temp = array[min]; array[min] = array[i]; array[i] = temp; } }
for ( int i = 0; i < array.length; i++ ) { System.out.print(array[i]); } } } |