Advertisement
vitormartinotti

Untitled

May 28th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. int m[51][51], somaL[51], somaC[51];
  4.  
  5. int main(){
  6.     int n; scanf("%d", &n);
  7.  
  8.     for(int i = 0; i < n; i++){
  9.         for(int j = 0; j < n; j++){
  10.             scanf("%d", &m[i][j]);
  11.             somaL[i] += m[i][j];
  12.             somaC[j] += m[i][j];
  13.         }
  14.     }
  15.  
  16.     int certa;
  17.     if(somaL[0] == somaL[1]){
  18.         certa = somaL[0];
  19.     }
  20.     else{
  21.         certa = somaL[2];
  22.     }
  23.  
  24.     int linha_errado, coluna_errado;
  25.     for(int i = 0; i < n; i++){
  26.         if(somaL[i] != certa){
  27.             linha_errado = i;
  28.             break;
  29.         }
  30.     }
  31.     for(int j = 0; j < n; j++){
  32.         if(somaC[j] != certa){
  33.             coluna_errado = j;
  34.             break;
  35.         }
  36.     }
  37.     printf("%d %d", certa - (somaL[linha_errado]-m[linha_errado][coluna_errado]), m[linha_errado][coluna_errado]);
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement