poj 1573 Robot Motion

本文详细记录了一次在解决简单模拟题时遇到的困难,主要原因是对题目的英文表述理解不准确及忽视了题目细节。通过实例分析,强调了英文阅读能力和仔细审题的重要性。分享了作者在解题过程中的思考和解决方案,最终成功解决了问题。

http://acm.pku.edu.cn/JudgeOnline/problem?id=1573

一个简单的模拟题,

写这篇解题报告用于告诫英语跟我一样烂的兄弟姐妹们,

"whether or not the number before it is 1"意为:

无论前面的数字是否为1,step后面都要跟(s), 也就是无论前面的数字是什么, 都是step(s)

为此, 鄙人光荣的贡献了2个WA,囧

也怪自己没仔细去看题目, 想当然的以为当步数小于1时, 应该写成step....

ps: 被难题虐是应该的, 被水题虐得死去活来的是在不应该啊...- -

#include<iostream> using namespace std; int main() { int row, col, t, i, j, step[10][10], tmp, st, loopst; char c[10][11]; bool visted[10][10], isLoop, isExit; while(scanf("%d%d%d", &row, &col, &t) && (row||col||t)) { memset(visted, 0, sizeof(visted)); for(i=0; i<row; i++) scanf("%s", c[i]); i = 0, j = t-1; visted[i][j] = 1; step[i][j] = 0; isLoop = isExit = false; st = 0; while(1) { st++; tmp = step[i][j]; switch(c[i][j]) { case 'S': i++; break; case 'N': i--; break; case 'E': j++; break; case 'W': j--; break; default: break; } if(i<0 || i>=row || j<0 || j>=col) { isExit = true; break; } else if(visted[i][j]) { isLoop = true; st = step[i][j]; loopst = tmp - step[i][j] + 1; break; } step[i][j] = tmp+1; visted[i][j] = 1; } if(isExit) printf("%d step(s) to exit/n", st); else if(isLoop) printf("%d step(s) before a loop of %d step(s)/n", st, loopst); } return 0; }

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值