Advertisement
SkyHawk

C qsort()

Jul 6th, 2011
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <algorithm>
  2. using namespace std;
  3.  
  4. int cmp(const void* a,const void* b)
  5. {
  6.     if(*reinterpret_cast<const int*>(a)>*reinterpret_cast<const int*>(b))
  7.         return 1;
  8.     if(*reinterpret_cast<const int*>(a)<*reinterpret_cast<const int*>(b))
  9.         return -1;
  10.     return 0;
  11. }
  12.  
  13. void cQSort(int* a,int l)
  14. {
  15.     qsort(a,l,sizeof(int),cmp);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement