fork(6) download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int Cmp(const void *lhs, const void *rhs) {
  6. return ((const int *)lhs)[1]-((const int *)rhs)[1];
  7. }
  8. int main() {
  9. int a[3][2] = {{0,3},{1,2},{2,1}};
  10. qsort(a,3,sizeof(a[0]),Cmp);
  11. for (int i = 0; i < 3; i++) {
  12. cout << a[i][0] << ' ' << a[i][1] << endl;
  13. }
  14. return 0;
  15. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
2 1
1 2
0 3