Notice
Recent Posts
Recent Comments
Link
삐까냥의 파도타기
버블 정렬 본문
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.length; i++ ) { for ( int j = 0; j < array.length - i; j++ ) { if ( array[j] > 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]); } } } |