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