Advertisement
Josif_tepe

Untitled

Jun 10th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main() {
  7. int n, m;
  8. scanf("%d%d", &n, &m);
  9. int matrica[n][m];
  10. for(int i = 0; i < n; i++) {
  11. for(int j = 0; j < m; j++) {
  12. scanf("%d", &matrica[i][j]);
  13. }
  14. }
  15. int brojac = 0;
  16. for(int i = 0; i < n; i++) {
  17.  
  18. for(int j = 0; j < m - 2; j++) {
  19. if(matrica[i][j] == 1 && matrica[i][j + 1] == 1 && matrica[i][j + 2] == 1) {
  20. brojac++;
  21. break;
  22. }
  23. }
  24. }
  25.  
  26. for(int j = 0; j < m; j++) {
  27. for(int i = 0; i < n - 2; i++) {
  28. if(matrica[i][j] == 1 && matrica[i + 1][j] == 1 && matrica[i + 2][j] == 1) {
  29. brojac++;
  30. break;
  31. }
  32. }
  33. }
  34. printf("%d\n", brojac);
  35.  
  36. return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement