Advertisement
Infiniti_Inter

First positive element in cow

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