fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N = 4;
  5. bool MATRIX[N][N] = {{0, 0, 1, 0},
  6. {0, 0, 1, 0},
  7. {0, 0, 0, 0},
  8. {0, 0, 1, 0}};
  9.  
  10. bool knows(int a, int b)
  11. {
  12. return MATRIX[a][b];
  13. }
  14.  
  15. int main() {
  16. int i = 0;
  17. int j = 1;
  18. int k = 2;
  19. while (k < N) {
  20. if (knows(i, j)) {
  21. i = k++;
  22. } else {
  23. j = k++;
  24. }
  25. }
  26. int c;
  27. if (knows(i, j)) {
  28. c = j;
  29. } else {
  30. c = i;
  31. }
  32. cout << "i: " << c << " and j: " << j << endl;
  33. return 0;
  34. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
i: 2 and j: 2