Advertisement
Guest User

bubblesort

a guest
May 31st, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. void order_vec( int a[], int n ){
  2.     int i, j;
  3.     for(i = 0; i < n; i++){         // Make a pass through the array for each element
  4.       for(j = 1; j < (n-i); j++){           // Go through the array beginning to end
  5.             if(a[j-1] > a[j])       // If the the first number is greater, swap it
  6.                 SWAP(a[j-1],a[j]);
  7.         }
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement