Robot Motion_POJ
来源:互联网 发布:如何打造网络爆款微信 编辑:程序博客网 时间:2024/06/05 16:18
大一上学期做的题
#include <stdio.h>#include <string.h>#define maxn 510struct Mj{ int h,t,r;}stu[maxn];int main(void){ int n,m,l; while(scanf("%d %d %d%*c",&n,&m,&l)){ if(n==0&&m==0&&l==0) { break; } else { int f[maxn][maxn]={0}; char s[maxn][maxn]={"0"}; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%c",&s[i][j]); } getchar(); } int k,num,o,u; k=1; u=o=num=0; char ch=s[k][l]; f[k][l]=1; stu[u].r=k; stu[u].t=l; stu[u++].h=num; while((ch=='N'||ch=='S'||ch=='E'||ch=='W')&&o!=1) { switch(ch) { case 'N':--k,ch=s[k][l],f[k][l]++;break; case 'S':++k,ch=s[k][l],f[k][l]++;break; case 'E':++l,ch=s[k][l],f[k][l]++;break; case 'W':--l,ch=s[k][l],f[k][l]++;break; }num++; if(f[k][l]>1) { o=1; } if(f[k][l]==1&&o!=1) { stu[u].r=k; stu[u].t=l; stu[u].h=num; u++; } } if(o!=1) printf("%d step(s) to exit\n",num); else { for(int i=0;i<u;i++) { if(stu[i].r==k&&stu[i].t==l) { printf("%d step(s) before a loop of %d step(s)\n",stu[i].h,num-stu[i].h); break; } } } }} return 0;}
0 0
- Robot Motion_POJ
- Robot
- robot
- robot
- Robot
- Robot
- Mobile Robot
- Simulation Robot
- web robot
- Web Robot
- gtalk robot
- robot.txt
- 1321. Robot
- Robot Motion
- 1321. Robot
- Robot畅想曲
- Robot Motion
- Robot Framework
- 如何修改js的编码格式?
- 使用Oracle Data Integrator Studio创建资料档案库
- hash table easy
- Redis Too many open files
- 蓝牙之数据传输问题
- Robot Motion_POJ
- vs15+opencv3.0.0+win7+32位
- ODI 创建Java EE Agent
- hadoop中的排序新思路-附基于spark之上的性能测试
- web前端简历怎么写?
- ODI Studio拓扑结构的创建与配置(MySQL)
- 机器学习实战——KNN代码
- hash table summary
- window10中安装elasticsearch