fork(1) download
  1. #include <iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4.  
  5. static int cnt;
  6.  
  7. int compare(const void *a, const void *b)
  8. {
  9. cnt+=1;
  10. int l = *(int*)a;
  11. int r= *(int*)b;
  12. return l-r;
  13. }
  14.  
  15. int main() {
  16. // your code goes here
  17. int a[]= {10,9,8,7,6,5};
  18. int size= sizeof(a)/sizeof(a[0]);
  19. int i;
  20. qsort(a,size,sizeof(int),compare);
  21.  
  22. for(i=0;i<6;i++)
  23. cout<<a[i]<<" ";
  24.  
  25. cout<<endl<<cnt<<endl;
  26. return 0;
  27. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
5 6 7 8 9 10 
9