Advertisement
SkyHawk

Selection Sort

Jul 6th, 2011
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement