Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int main() {
- int n, m;
- scanf("%d%d", &n, &m);
- int matrica[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &matrica[i][j]);
- }
- }
- int brojac = 0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m - 2; j++) {
- if(matrica[i][j] == 1 && matrica[i][j + 1] == 1 && matrica[i][j + 2] == 1) {
- brojac++;
- break;
- }
- }
- }
- for(int j = 0; j < m; j++) {
- for(int i = 0; i < n - 2; i++) {
- if(matrica[i][j] == 1 && matrica[i + 1][j] == 1 && matrica[i + 2][j] == 1) {
- brojac++;
- break;
- }
- }
- }
- printf("%d\n", brojac);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement