POJ1132
来源:互联网 发布:程序员公众号 编辑:程序博客网 时间:2024/05/17 21:46
*题目大意*:
有一个封闭路径, 打印边缘。
*解题思路*:
直接模拟, 四个方向分别对应设置地图标记。
由于地图采用二维数组存储, 打印地图的时候注意需要改变坐标。
注意输入还附带一行。
*代码*:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int map[35][35];void get_point(){ int x, y; char str[3000]; scanf("%d%d", &x, &y); int i; scanf("%s", str); for (i=0; str[i]!='.'; i++) { switch(str[i]) { case 'E': map[x][y-1] = 1; x = x+1; y = y; break; case 'N': map[x][y] = 1; x = x; y = y+1; break; case 'W': map[x-1][y] = 1; x = x-1; y = y; break; case 'S': map[x-1][y-1] = 1; x = x; y = y-1; break; } }}int main(){ // freopen("1.txt", "r", stdin); int t; scanf("%d", &t); int n = t; while (t--) { memset(map, 0, sizeof(map)); get_point(); printf("Bitmap #%d\n", n-t); int i, j; for (i=0; i<32; i++) { for (j=0; j<32; j++) { if (map[j][31-i]) printf("X"); else printf("."); } putchar('\n'); } putchar('\n'); } return 0;}
0 0
- POJ1132
- POJ1132 Border
- poj1132 简单模拟
- 搜索空间中解不唯一的例子:完美立方
- 百度地图自定义大头针
- Android uevent
- JavaScript产生随机数并对数据进行简单的运算
- UVA - 1368 DNA Consensus String
- POJ1132
- 母牛生小牛
- CODEVS 1022 覆盖 解题报告
- [LeetCode][Java] Binary Tree Zigzag Level Order Traversal
- QT获取网页内容
- PyQt的安装和使用案例
- zookeeper原理
- Project Euler:Problem 81 Path sum: two ways
- HDU 1037