Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- int puzzle[10][10] = { -1 };
- int main() {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int n, m, count = 0;
- scanf("%d%d", &n, &m);
- for (int i = 0; i < n; i++) {
- count = 0;
- for (int j = 0; j < m; j++) {
- scanf("%d", &puzzle[i][j]);
- if (puzzle[i][j] == 1) {
- count++;
- //printf("%d", count);
- }
- else if (count != 0) {
- printf("%d ", count);
- count = 0;
- }
- //printf("%d ", puzzle[i][j]);
- }
- if (count != 0) {
- printf("%d ", count);
- count = 0;
- }
- printf("\n");
- }
- for (int j = 0; j < m; j++) {
- count = 0;
- for (int i = 0; i < n; i++) {
- if (puzzle[i][j] == 1) {
- count++;
- }
- else if (count != 0) {
- printf("%d ", count);
- count = 0;
- }
- }
- if (count != 0) {
- printf("%d ", count);
- count = 0;
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement