STANAANDREY

sb prog 7

Feb 23rd, 2022 (edited)
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int n, m;
  7.     cin >> n >> m;
  8.     int a[n][m];
  9.     for (int i = 0; i < n; i++) {
  10.         for (int j = 0; j < m; j++) {
  11.             cin >> a[i][j];
  12.         }
  13.     }
  14.  
  15.     for (int i = 0; i < n; i++) {
  16.         int sum = 0, hasEven = 0;
  17.         for (int j = 0; j < m; j++) {
  18.             if (a[i][j] % 2 == 0) {
  19.                 sum += a[i][j];
  20.                 hasEven = 1;
  21.             }
  22.         }
  23.         if (hasEven) {
  24.             cout << "Pe linia " << i << " suma este " << sum << endl;
  25.         } else {
  26.             cout << "Pe linia " << i << " nu exista nr. pare!" << endl;
  27.         }
  28.     }
  29.     return 0;
  30. }
  31.  
Add Comment
Please, Sign In to add comment