Advertisement
Guest User

Osobowosc

a guest
Mar 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.         int d, n;
  6.         cin >> d;
  7.         for (int i = 0; i< d ; i++) {
  8.             cin >> n;
  9.             int tab[n][n];
  10.             for (int j = 0; j< n; j++) {
  11.                 for (int k = 0; k< n; k++) {
  12.                     cin >> tab[j][k];
  13.                 }
  14.             }
  15.             int j =0, k =0;
  16.             while((j < n) && (k < n)) {
  17.                 if (tab[j][k]==1) {
  18.                     j++;
  19.                 } else {
  20.                     k++;
  21.                 }
  22.             }
  23.             if (j == n) {
  24.                 cout << (k+1) << "\n";
  25.             } else {
  26.                 cout << (j+1) << "\n";
  27.             }
  28.         }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement