Advertisement
LegoDrifter

Linii bugged

Jun 19th, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int mat[100][100];
  7.     int n,m;
  8.     scanf("%d%d",&n,&m);
  9.     int i,j;
  10.     int brojac=0;
  11.     int flag=0;
  12.     int brojce=0;
  13.     for(i=0;i<n;i++)
  14.     {
  15.         for(j=0 ;j<m;j++)
  16.         {
  17.             scanf("%d",&mat[i][j]);
  18.         }
  19.     }
  20.     printf("\n");
  21.     for(i=0;i<n;i++)
  22.     {
  23.         brojac=0;
  24.         for(j=0;j<m;j++)
  25.         {
  26.            if(mat[i][j]==1)
  27.            {
  28.                flag=1;
  29.                brojac++;
  30.                if(brojac>2)
  31.                 brojce++;
  32.  
  33.            }
  34.            else if(flag)
  35.            {
  36.                flag=0;
  37.                brojac=0;
  38.            }
  39.  
  40.         }
  41.  
  42.     }
  43.  
  44.     for(j=0;j<m;j++)
  45.     {
  46.         brojac=0;
  47.         for(i=0;i<n;i++)
  48.         {
  49.         if(mat[i][j]==1)
  50.            {
  51.                flag=1;
  52.                brojac++;
  53.                if(brojac>2)
  54.                 brojce++;
  55.  
  56.            }
  57.            else if(flag)
  58.            {
  59.                flag=0;
  60.                brojac=0;
  61.            }
  62.         }
  63.     }
  64.  
  65.     printf("%d",brojce);
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement