STANAANDREY

gr inc

Feb 15th, 2021 (edited)
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define NMAX 103
  4. int n, m;
  5. int inc[NMAX][NMAX], d[NMAX][2];
  6.  
  7. void read() {
  8.     cin >> n >> m;
  9.     for (int i = 1; i <= n; i++) {
  10.         for (int j = 1; j <= m; j++) {
  11.             cin >> inc[i][j];
  12.         }
  13.     }
  14. }
  15.  
  16. void solve() {
  17.     for (int j = 1; j <= n; j++) {
  18.         for (int i = 1; i <= m; i++) {
  19.             if (inc[i][j] == 1) {
  20.                 d[i][0]++;
  21.             }
  22.             if (inc[i][j] == -1) {
  23.                 d[i][1]++;
  24.             }
  25.         }
  26.     }
  27. }
  28.  
  29. void write() {
  30.     for (int i = 0; i <= 1; i++) {
  31.         for (int j = 1; j <= n; j++) {
  32.             cout << 'd' << ((i) ? '-' : '+') << '[' << j << "]=" << d[j][i] << endl;
  33.         }
  34.     }//*/
  35. }
  36.  
  37. int main() {
  38.     read();
  39.     solve();
  40.     write();
  41.     return 0;
  42. }
  43.  
Add Comment
Please, Sign In to add comment