Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void bubbleSort(int a[]) {
- int size = a.length;
- for(int i=size-1; i>0; i--) {
- System.out.printf("\n버블 정렬 %d 단계 : ", size-i);
- for(int j=0; j<i; j++) {
- if(a[j] > a[j+1]) {
- swap(a,j,j+1);
- }
- System.out.printf("\n\t");
- for(int v : a) {
- System.out.printf("%3d ", v);
- }
- }
- }
- System.out.println();
- }
- public void swap(int a[], int idx1, int idx2) {
- int temp = a[idx1];
- a[idx1] = a[idx2];
- a[idx2] = temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement