Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, m; scanf("%d %d", &n, &m);
- int campo[n][m];
- //Leitura da matriz
- for(int i = 0; i < n; i++){
- for(int j = 0; j < m; j++){
- scanf("%d", &campo[i][j]);
- }
- }
- //Soma das lihas e colunas
- int somaL[n], somaC[m];
- for(int k = 0; k < n; k++){
- somaL[k] = 0;
- }
- for(int k = 0; k < m; k++){
- somaC[k] = 0;
- }
- for(int i = 0; i < n; i++){
- for(int j = 0; j < m; j++){
- somaL[i] += campo[i][j];
- somaC[j] += campo[i][j];
- }
- }
- int maior = -1;
- for(int k = 0; k < n; k++){
- if (somaL[k] > maior){
- maior = somaL[k];
- }
- }
- for(int k = 0; k < m; k++){
- if (somaC[k] > maior){
- maior = somaC[k];
- }
- }
- printf("%d", maior);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement