Advertisement
LegoDrifter

Linii :')

Jun 19th, 2020
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 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) // Ako imat vrednost 1 se krevat znameto.
  27.            {
  28.                flag=1;
  29.                brojac++; // Brojacot se zgolemuvat
  30.                if(brojac>2) // Ako brojacot e pogolem od 2 togas dobivme edna kombinacija
  31.                {
  32.                 brojce++; // brojce( sry for the name ) e brojac za kombinacii
  33.                    break; // pravime break bidejki bez break ako ima 1111 ke gi cita kako dve dobieni kombinacii
  34.                }
  35.                
  36.  
  37.            }
  38.            else if(flag) // Ako gore padnal uslovot znaci nemame poveke edinica.
  39.            {
  40.                flag=0; // Flag go spustame dolu
  41.                brojac=0; // Brojacot go resetirame.
  42.            }
  43.  
  44.         }
  45.  
  46.     }
  47.    
  48.     for(j=0;j<m;j++)
  49.     {
  50.         brojac=0;
  51.         for(i=0;i<n;i++)
  52.         {
  53.         if(mat[i][j]==1)
  54.            {
  55.                flag=1;
  56.                brojac++;
  57.                if(brojac>2)
  58.               {
  59.                 brojce++;
  60.                    break;
  61.                }
  62.  
  63.            }
  64.            else if(flag)
  65.            {
  66.                flag=0;
  67.                brojac=0;
  68.            }
  69.         }
  70.     }
  71.  
  72.     printf("%d",brojce);
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement