Advertisement
vim_fans

Untitled

Nov 23rd, 2021
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1.  
  2. void swap(int v[], int k)
  3. {
  4.    
  5.     int temp;
  6.     temp = v[k];
  7.     v[k] = v[k+1];
  8.     v[k+1] = temp;
  9. }
  10.  
  11. void sort (int v[], int n)
  12. {
  13.     int i,j;
  14.     for(i=0; i<n;i+=1){
  15.        
  16.         for(j = i-1;j>=0 && v[j]>v[j+1];j=1){
  17.             swap(v,j);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement