Advertisement
josiftepe

Untitled

Dec 18th, 2022
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n1, n2; // bidejki ima dve matrici, n1 ke bide za prvata matrica, a n2 za vtorata
  6.     cin >> n1 >> n2;
  7.    
  8.     int mat1[n1][n1];
  9.     int mat2[n2][n2];
  10.    
  11.     int zbir1 = 0;
  12.     for(int i = 0; i < n1; i++) {
  13.         for(int j = 0; j < n1; j++) {
  14.             cin >> mat1[i][j];
  15.             zbir1 += mat1[i][j];
  16.         }
  17.     }
  18.     int zbir2 = 0;
  19.     for(int i = 0; i < n2; i++) {
  20.         for(int j = 0; j < n2; j++) {
  21.             cin >> mat2[i][j];
  22.             zbir2 += mat2[i][j];
  23.         }
  24.     }
  25.    
  26.     if(zbir1 > zbir2) {
  27.         cout << zbir1 << endl;
  28.         for(int i = 0; i < n1; i++) {
  29.             for(int j = 0; j < n1; j++) {
  30.                 cout << mat1[i][j] << " ";
  31.             }
  32.             cout << endl;
  33.         }
  34.     }
  35.     else {
  36.         cout << zbir2 << endl;
  37.         for(int i = 0; i < n2; i++) {
  38.             for(int j = 0; j < n2; j++) {
  39.                 cout << mat2[i][j] << " ";
  40.             }
  41.             cout << endl;
  42.         }
  43.     }
  44.     return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement