Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- int a[n][m];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cin >> a[i][j];
- }
- }
- for (int i = 0; i < n; i++) {
- int sum = 0, hasEven = 0;
- for (int j = 0; j < m; j++) {
- if (a[i][j] % 2 == 0) {
- sum += a[i][j];
- hasEven = 1;
- }
- }
- if (hasEven) {
- cout << "Pe linia " << i << " suma este " << sum << endl;
- } else {
- cout << "Pe linia " << i << " nu exista nr. pare!" << endl;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment