목록코딩/기타 (3)
삐까냥의 파도타기
public class SortBubble {public static void main(String[] agr){int[] array = {5,7,8,4,6,9,2,3,1};//버블for ( int i = 1; i array[j+1] ) {int temp = array[j];array[j] = array[j+1];array[j+1] = temp;}}}for ( int i = 0; i < array.length; i++ ) {System.out.print(array[i]);}}}
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 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]);}}}
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[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]);}}}