SkyHawk

Bubble Sort Opt

Jul 6th, 2011
280
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define FOR(i,n) for(int i = 0;i < n;++i)
  2.  
  3. void bubleSortM(int* p,int l)
  4. {
  5.     int temp;
  6.     int k = l-1;
  7.     for(int i = l-1;i>0;--i)
  8.     {
  9.         k=0;
  10.         FOR(q,i)
  11.             if(p[q]<p[q+1])
  12.                 {temp = p[q]; p[q] = p[q+1]; p[q+1] = temp;k = q+1;}
  13.         i = k;
  14.     }
  15. }
RAW Paste Data