Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3.  
  4. int puzzle[10][10] = { -1 };
  5.  
  6. int main() {
  7.     freopen("input.txt", "r", stdin);
  8.     freopen("output.txt", "w", stdout);
  9.  
  10.     int n, m, count = 0;
  11.     scanf("%d%d", &n, &m);
  12.     for (int i = 0; i < n; i++) {
  13.         count = 0;
  14.         for (int j = 0; j < m; j++) {
  15.             scanf("%d", &puzzle[i][j]);
  16.             if (puzzle[i][j] == 1) {
  17.                 count++;
  18.                 //printf("%d", count);
  19.             }
  20.             else if (count != 0) {
  21.                 printf("%d ", count);
  22.                 count = 0;
  23.             }
  24.             //printf("%d ", puzzle[i][j]);
  25.         }
  26.         if (count != 0) {
  27.             printf("%d ", count);
  28.             count = 0;
  29.         }
  30.         printf("\n");
  31.     }
  32.     for (int j = 0; j < m; j++) {
  33.         count = 0;
  34.         for (int i = 0; i < n; i++) {
  35.             if (puzzle[i][j] == 1) {
  36.                 count++;
  37.             }
  38.             else if (count != 0) {
  39.                 printf("%d ", count);
  40.                 count = 0;
  41.             }
  42.         }
  43.         if (count != 0) {
  44.             printf("%d ", count);
  45.             count = 0;
  46.         }
  47.         printf("\n");
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement