fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N, M, i, j, mat[1000][1000],mat2 = 0;
  6. cin >> N >> M;
  7. for(i = 1;N >= i;++i){
  8. for(j = 1;M >= j;++j)
  9. cin >> mat[i][j];
  10. }
  11. for(i = 1;N >= i;++i){
  12. for(j = 1;M >= j;++j)
  13. mat2 += mat[i][j];
  14. }
  15. cout << mat2;
  16. return 0;
  17. }
Success #stdin #stdout 0s 5512KB
stdin
4 5
9 9 9 9 9 
8 8 8 8 8
7 7 7 7 7
6 6 6 6 6
stdout
150