Advertisement
Josif_tepe

Untitled

Jan 11th, 2024
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <ctype.h>
  4. int main(int argc, const char * argv[])
  5. {
  6.     int n, m;
  7.     scanf("%d%d", &n, &m);
  8.    
  9.     int mat[n][m];
  10.     for(int i =0 ; i < n; i++) {
  11.         for(int j = 0; j < m; j++) {
  12.             scanf("%d", &mat[i][j]);
  13.         }
  14.     }
  15.     int najgolem = 0;
  16.     for(int i = 0; i < n; i++) {
  17.         int brojac =0 ;
  18.         for(int j = 0; j < m; j++) {
  19.            
  20.             if(mat[i][j] == 1) {
  21.                 brojac++;
  22.             }
  23.             else {
  24.                 brojac = 0;
  25.             }
  26.             if(brojac > najgolem) {
  27.                 najgolem = brojac;
  28.             }
  29.            
  30.         }
  31.     }
  32.     for(int j = 0; j < m; j++) {
  33.         int brojac =0 ;
  34.         for(int i = 0; i < n; i++) {
  35.            
  36.             if(mat[i][j] == 1) {
  37.                 brojac++;
  38.             }
  39.             else {
  40.                 brojac = 0;
  41.             }
  42.             if(brojac > najgolem) {
  43.                 najgolem = brojac;
  44.             }
  45.            
  46.         }
  47.     }
  48.     printf("%d\n", najgolem);
  49.     return 0;
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement