fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m;
  5. scanf("%d %d", &n, &m);
  6. int array[n][m];
  7.  
  8. for(int i=0; i<n; i++){
  9. for(int j=0; j<m; j++){
  10. scanf("%d", &array[i][j]);
  11. }
  12. }
  13. int odd=0,even=0,positive=0,negative=0;
  14. for(int i=0; i<n; i++){
  15. for(int j=0; j<m; j++){
  16. if(array[i][j] % 2 == 0) even++;
  17. else odd++;
  18.  
  19. if(array[i][j] >= 0) positive++;
  20. else negative++;
  21. }
  22. }
  23. printf("Even: %d\n", even);
  24. printf("Odd : %d\n", odd);
  25. printf("Positive: %d\n", positive);
  26. printf("Negative: %d\n", negative);
  27. }
  28.  
  29.  
Success #stdin #stdout 0.01s 5280KB
stdin
3 3
2 -3 -9
-1 0 1
3 4 8
stdout
Even: 4
Odd : 5
Positive: 6
Negative: 3