Advertisement
KristijanT

Arrays and Matrices (6)_Lines FINKI

Nov 23rd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAX 100
  4.  
  5. int main()
  6. {
  7.     int m, n;
  8.     scanf("%d%d", &m, &n);
  9.     int i, j;
  10.     int mat[MAX][MAX];
  11.     for (i=0;i<m;i++)
  12.     {
  13.         for (j=0;j<n;j++)
  14.         {
  15.             scanf("%d", &mat[i][j]);
  16.         }
  17.     }
  18.     int prev=0; int counter=0; int zbir=0;
  19.     for (i=0;i<m;i++)
  20.     {
  21.         for (j=0;j<n;j++)
  22.         {
  23.             if (mat[i][j]==1) counter++;
  24.             else if (mat[i][j]==0) counter=0;
  25.             if (counter==3) {zbir++; break;}
  26.             //printf("%d", mat[i][j]);
  27.         }
  28.         counter=0;
  29.         //printf("\n");
  30.     }
  31.  
  32.     for (j=0;j<n;j++)
  33.     {
  34.         for (i=0;i<m;i++)
  35.         {
  36.             if (mat[i][j]==1) counter++;
  37.             else if (mat[i][j]==0) counter=0;
  38.             if (counter==3) {zbir++; break;}
  39.             //printf("%d", mat[i][j]);
  40.         }
  41.             counter=0;
  42.             //printf("\n");
  43.     }
  44.     printf("%d\n", zbir);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement