diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2016-11-09 11:02:27 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2016-11-09 11:02:27 +0700 |
commit | 94f49ef11037832a173d268ca932fe34cf78b472 (patch) | |
tree | a83438f7e5f0f04ba32a469051b7671782fefb8b /others/coastline/grid.c | |
parent | 90eb5475115ecf6725f028ec3c39fab95afcb458 (diff) | |
download | cp-94f49ef11037832a173d268ca932fe34cf78b472.tar.gz |
Thêm kì thi thử Duyên Hải
Diffstat (limited to 'others/coastline/grid.c')
-rw-r--r-- | others/coastline/grid.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/others/coastline/grid.c b/others/coastline/grid.c new file mode 100644 index 0000000..b468190 --- /dev/null +++ b/others/coastline/grid.c @@ -0,0 +1,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; +} |