SkyHawk

C qsort()

Jul 6th, 2011
267
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data