티스토리 뷰


package cbnu;


public class Select {


public static void main(String[] args) {

// TODO Auto-generated method stub


int array[] = { 1024, 512, 16, 8, 256, 64, 2048, 9048, 4096, 2, 1023 };


for (int i = 0; i < array.length - 1; i++) {

for (int j = i+1; j < array.length; j++) {

if (array[i] > array[j])

swap(array, i, j);

}

}


for (int i = 0; i < array.length; i++) {

System.out.print(" " + array[i]);

}

}


private static void swap(int[] array, int i, int j) {

// TODO Auto-generated method stub

int temp = array[i];

array[i] = array[j];

array[j] = temp;

}


}





댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함