Advertisement
Josif_tepe

Untitled

Apr 16th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n, m;
  6.     int zbir = 0;
  7.     cin >> n >> m;
  8.     int mat[n][m];
  9.     for(int i = 0; i < n; i++) {
  10.         for(int j = 0; j < m; j++) {
  11.             cin >> mat[i][j];
  12.         }
  13.     }
  14.    
  15.     for(int i = 0; i < n; i++) {
  16.         zbir += mat[i][i];
  17.     }
  18.     cout << zbir << endl;
  19.     return 0;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement