Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- float mat[n][n];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cin >> mat[i][j];
- }
- }
- float zbir_nad_sporedna_dijagonala = 0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n - 1 - i; j++) {
- zbir_nad_sporedna_dijagonala += mat[i][j];
- }
- }
- float zbir_pod_sporedna_dijagonala = 0;
- for(int i = 0; i < n; i++) {
- for(int j = n - i; j < n; j++) {
- zbir_pod_sporedna_dijagonala += mat[i][j];
- }
- }
- cout << zbir_nad_sporedna_dijagonala << " " << zbir_pod_sporedna_dijagonala << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement