Advertisement
Josif_tepe

Untitled

Dec 18th, 2022
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.    
  9.     float mat[n][n];
  10.     for(int i = 0; i < n; i++) {
  11.         for(int j = 0; j < n; j++) {
  12.             cin >> mat[i][j];
  13.         }
  14.     }
  15.    
  16.     float zbir_nad_sporedna_dijagonala = 0;
  17.     for(int i = 0; i < n; i++) {
  18.         for(int j = 0; j < n - 1 - i; j++) {
  19.             zbir_nad_sporedna_dijagonala += mat[i][j];
  20.         }
  21.     }
  22.    
  23.     float zbir_pod_sporedna_dijagonala = 0;
  24.     for(int i = 0; i < n; i++) {
  25.         for(int j = n - i; j < n; j++) {
  26.             zbir_pod_sporedna_dijagonala += mat[i][j];
  27.         }
  28.     }
  29.     cout << zbir_nad_sporedna_dijagonala << " " << zbir_pod_sporedna_dijagonala << endl;
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement