SkyHawk

Selection Sort

Jul 6th, 2011
648
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void selSort(int* p,int l)
  2. {
  3.     int max = p[0];
  4.     int maxn = 0;
  5.     for(int i = 0;i<l-1;++i)
  6.     {
  7.         for(int j = i;j<l;++j)
  8.             if(p[j]>max)
  9.             {
  10.                 max = p[j];
  11.                 maxn = j;
  12.             }
  13.         int t = p[i];
  14.         p[i] = max;
  15.         p[maxn] = t;
  16.     }
  17. }
RAW Paste Data