about summary refs log tree commit diff
path: root/others/coastline/grid.c
blob: b468190202e96756570a203b3e5cd35f7a3345dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>

int main()
{
	char w, h, i, j, t = -1, r = -1, b = -1, l = -1;

	scanf("%hhd %hhd\n", &h, &w);

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++)
			if (getchar() == 42) {
				if (t < 0 && l < 0) {
					t = i;
					l = j;
				}
				b = (b < i) ? i : b;
				r = (r < j) ? j : r;
			}
		getchar();
	}

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++)
			if (i >= t && i <= b && j >= l && j <= r)
				putchar(42);
			else
				putchar(46);
		putchar(10);
	}

	return 0;
}