Advertisement
Alx09

bubbleSort

Oct 6th, 2021
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. void bubble(int a[],int n)
  2. {
  3.     int i,schimbat,aux;
  4.     do {
  5.         schimbat = 0;
  6.         // parcurgem vectorul
  7.         for(i = 0; i < n-1; i++) {
  8.        
  9.             if (a[i] > a[i+1]) {
  10.                
  11.             aux = a[i];
  12.         a[i] = a[i+1];
  13.         a[i+1] = aux;
  14.         schimbat = 1;
  15.         }
  16.         }
  17.     } while(schimbat);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement