POJ 1573 *** Robot Motion
来源:互联网 发布:淘宝四钻买家花多少钱 编辑:程序博客网 时间:2024/06/05 11:01
题意:有一个ROW*COL的矩形,其中每一个1*1的小块上有NSWE四个方向,一个机器人站在这上面,按照指定方向前进,问最后小机器人能不能出去或者在里面怎么循环。
想法:建一个矩形,然后按照提示每一步走就行了。。这几天做的模拟题都好水。。。
代码如下:
#pragma warning(disable:4996)#include<iostream>#include<cstdio>#include<cmath>#include<stack>#include<cstring>#include<sstream>#include<set>#include<string>#include<iterator>#include<vector>#include<map>#include<algorithm>using namespace std;int mmap[15][15];char m[15][15];int main() {//freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout);int row, col,step,x,y;char sign;string str[15];while (cin >> col >> row >> x, col || row || x) {memset(mmap, 0, sizeof(mmap));for (int i = col; i >= 1; --i)for (int j = 1; j <= row; ++j)cin >> m[j][i];step = 1;y = col;while (x > 0 && x <= row&&y > 0 && y <= col&&(!mmap[x][y])) {mmap[x][y] = step;sign = m[x][y];if (sign == 'N') y++;else if (sign == 'S')y--;else if (sign == 'W') x--;else if (sign == 'E') x++;step++;}if (mmap[x][y])cout << mmap[x][y] - 1 << " step(s) before a loop of " << step - mmap[x][y] << " step(s)" << endl;else cout << step-1<<" step(s) to exit" << endl;}return 0;}
0 0
- poj 1573 Robot Motion
- Poj 1573 Robot Motion
- poj 1573 Robot Motion
- POJ 1573 - Robot Motion
- poj-1573-Robot Motion
- POJ 1573 Robot Motion
- POJ 1573 Robot Motion
- POJ-1573-Robot Motion
- poj 1573 Robot Motion
- POJ 1573 Robot Motion
- POJ 1573 Robot Motion.
- poj 1573 Robot Motion
- POJ -1573 Robot Motion
- POJ 1573:Robot Motion
- poj 1573 Robot Motion
- poj 1573 Robot Motion
- POJ 1573 Robot Motion
- Robot Motion POJ 1573
- Spring的核心技术(一)
- (二)分析与设计
- Android 屏幕适配方案
- Cocos2d-x v3.9发布
- Android Icon drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi
- POJ 1573 *** Robot Motion
- Android中的okHttp
- iOS开发系列—Objective-C之Foundation框架
- meclipse中project facet问题
- 在Activty中处理adapter中的监听事件的写法
- Android模拟位置信息
- 常用网站
- 【读书笔记】iOS网络-应用间通信
- python3.5 + selenium环境搭建