fork(6) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. const int N = 7;
  7. bool win[7][7]= {
  8. {0, 0, 1, 1, 1, 0, 1},
  9. {1, 0, 1, 1, 1, 1, 1},
  10. {0, 0, 0, 1, 1, 0, 0},
  11. {0, 0, 0, 0, 1, 0, 0},
  12. {0, 0, 0, 0, 0, 0, 0},
  13. {1, 0, 1, 1, 1, 0, 1},
  14. {0, 0, 1, 1, 1, 0, 0}
  15. };
  16.  
  17. bool compare(int i, int j) {
  18. return win[i][j];
  19. }
  20.  
  21. int main() {
  22. vector<int> res(N);
  23. for (int i=0; i<N; i++)
  24. res[i] = i;
  25.  
  26. sort(res.begin(), res.end(), compare);
  27.  
  28. for(auto v: res)
  29. cout << v << " ";
  30. cout << endl;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
1 5 0 6 2 3 4