Guest User

Untitled

a guest
Dec 16th, 2018
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 90.4.20
  2.  
  3. #include<iostream>
  4. #include<math.h>
  5. using namespace std;
  6.  
  7. const int N = 1e4;
  8.  
  9. bool used[N][N]; // статичная матрица логического типа
  10.  
  11. int a[N][N]; // статичная матрица
  12. int answer[2 * N];
  13.  
  14. int main()
  15. {
  16.     int n;
  17.     cout << "Enter n: " << endl;
  18.     cin >> n;
  19.     cout << "Enter matrix: " << endl;
  20.     for (int i = 0; i < n; ++i)
  21.         for (int j = 0; j < n; ++j)
  22.             cin >> a[i][j];
  23.     int cnt = 0;
  24.     for (int j = 0; j < n; ++j)
  25.         for (int i = 0; i < n; ++i)
  26.             {
  27.                 int cur = a[i][j];
  28.                 if (used[j][cur] == true)
  29.                     {
  30.                         for (int k = 0; k < i; k++)
  31.                             if (a[k][j] == cur)
  32.                                 {
  33.                                     answer[cnt++] = k;
  34.                                     break;
  35.                                 }
  36.                         answer[cnt++] = i;
  37.                         break;
  38.                     }
  39.                 else
  40.                     used[j][cur] = true;
  41.             }
  42.     for (int i = 0; i < cnt; i += 2)
  43.         cout << answer[i] + 1<< ' ' << answer[i + 1] + 1 << endl;
  44.     system ("pause");
  45.     return 0;
  46. }
Add Comment
Please, Sign In to add comment