Advertisement
Josif_tepe

Untitled

Apr 23rd, 2024
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n;
  6.     scanf("%d", &n);
  7.    
  8.     int mat[n][n];
  9.     for(int i = 0; i < n; i++) {
  10.         for(int j = 0; j < n; j++) {
  11.             scanf("%d", &mat[i][j]);
  12.         }
  13.     }
  14.  
  15.     int najgolem = 0;
  16.     for(int i = 0; i < n; i++) {
  17.         int brojac = 0;
  18.        
  19.         for(int j = 0; j < n; j++) {
  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 < n; j++) {
  33.         int brojac = 0;
  34.         for(int i = 0; i < n; i++) {
  35.             if(mat[i][j] == 1) {
  36.                 brojac++;
  37.             }
  38.             else {
  39.                 brojac = 0;
  40.             }
  41.             if(brojac > najgolem) {
  42.                 najgolem = brojac;
  43.             }
  44.         }
  45.     }
  46.     printf("%d\n", najgolem);
  47.  
  48.     return 0;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement