fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int x[100][100];
  6. int n, sum = 0, count = 0;
  7. cin >> n;
  8. for (int i = 0; i < n; i++) {
  9. for (int j = 0; j < n; j++) {
  10. cin >> x[i][j]; } }
  11. for (int i = 0; i < n; i++) {
  12. for (int j = 0; j < n; j++) {
  13. if (x[i][j] < 0 and x[i][j] % 2 == 0) {
  14. sum += x[i][j];
  15. count++;
  16. }
  17. }
  18. }
  19. cout << count << " " << sum;
  20. return 0;
  21. }
Success #stdin #stdout 0s 15232KB
stdin
3
2 -3 0
-2 -4 -6
6 -5 1
stdout
3 -12