#include<iostream>
#include<stdio.h>
#define MAXN 15
using namespace std; char _m[MAXN][MAXN];
bool mark[MAXN][MAXN];
int record[MAXN][MAXN]; int r;
int c;
void dfs(int i,int j);
int main()
{
//freopen("acm.acm","r",stdin);
int i;
int j;
int place;
while(cin>>r>>c>>place)
{
if(!r && !c && !place)
break;
-- place;
memset(mark,false,sizeof(mark));
// memset(record,0,sizeof(record));
for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
record[i][j] = ;
}
}
for(i = ; i < r; ++ i)
{
for(j = ; j < c; ++ j)
{
cin>>_m[i][j];
}
}
record[][place] = ;
mark[][place] = true;
dfs(,place);
// for(i = 0; i < r; ++ i)
// {
// for(j = 0; j < c; ++ j)
// {
// cout<<record[i][j]<<" ";
// }
// cout<<endl;
// }
}
}
void fun_1(int num);
void fun_2(int num,int num_1);
void dfs(int i,int j)
{
int tem1;
int tem2;
if(_m[i][j] == 'E')
{
if(j + < c)
{
if(!mark[i][j+])
{
mark[i][j+] = true;
record[i][j+] += record[i][j];
dfs(i,j+);
return ;
}
else
{
fun_2(record[i][j+]-,record[i][j]-record[i][j+]+);
return ;
}
}
else
{
fun_1(record[i][j]);
return ;
}
}/////////////////////// if(_m[i][j] == 'S')
{
if(i + < r)
{
if(!mark[i+][j])
{
mark[i+][j] = true;
record[i+][j] += record[i][j];
dfs(i+,j);
return ;
}
else
{
fun_2(record[i+][j]-,record[i][j]-record[i+][j]+);
return ;
}
}
else
{
fun_1(record[i][j]);
return ;
}
}////////////////////////////// if(_m[i][j] == 'W')
{
if(j - >= )
{
if(!mark[i][j-])
{
mark[i][j-] = true;
record[i][j-] += record[i][j];
dfs(i,j-);
return ;
}
else
{
fun_2(record[i][j-]-,record[i][j]-record[i][j-]+);
return ;
}
}
else
{
fun_1(record[i][j]);
return ;
}
}/////////////////////////////////////////// if(_m[i][j] == 'N')
{
if(i - >= )
{
if(!mark[i-][j])
{
mark[i-][j] = true;
record[i-][j] += record[i][j];
dfs(i-,j);
return;
}
else
{
fun_2(record[i-][j]-,record[i][j]-record[i-][j]+);
return ;
}
}
else
{
fun_1(record[i][j]);
return ;
}
}
} void fun_1(int num)
{
cout<<num;
// if(num != 1)
cout<<" step(s) to exit"<<endl;
// else
// cout<<" step to exit"<<endl;
} void fun_2(int num,int num_1)
{
cout<<num;
// if(num != 1)
cout<<" step(s) before a loop of ";
// else
// cout<<" step before a loop of ";
cout<<num_1;
// if(num_1 != 1)
cout<<" step(s)"<<endl;
// else
// cout<<" step"<<endl;
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1573的更多相关文章

  1. 模拟 POJ 1573 Robot Motion

    题目地址:http://poj.org/problem?id=1573 /* 题意:给定地图和起始位置,robot(上下左右)一步一步去走,问走出地图的步数 如果是死循环,输出走进死循环之前的步数和死 ...

  2. POJ 1573 Robot Motion(BFS)

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12856   Accepted: 6240 Des ...

  3. POJ 1573 Robot Motion(模拟)

    题目代号:POJ 1573 题目链接:http://poj.org/problem?id=1573 Language: Default Robot Motion Time Limit: 1000MS ...

  4. POJ 1573 Robot Motion 模拟 难度:0

    #define ONLINE_JUDGE #include<cstdio> #include <cstring> #include <algorithm> usin ...

  5. POJ 1573 Robot Motion

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12978   Accepted: 6290 Des ...

  6. POJ 1573 (13.10.11)

    Description A robot has been programmed to follow the instructions in its path. Instructions for the ...

  7. poj 1573 Robot Motion_模拟

    又是被自己的方向搞混了 题意:走出去和遇到之前走过的就输出. #include <cstdlib> #include <iostream> #include<cstdio ...

  8. poj 1573 Robot Motion【模拟题 写个while循环一直到机器人跳出来】

                                                                                                         ...

  9. Robot Motion - poj 1573

      Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11269   Accepted: 5486 Description A ...

随机推荐

  1. hdu 3530 Subsequence

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3530 Subsequence Description There is a sequence of i ...

  2. Linq To SQLite by CRUD

    1, 希望使用linqtoSQLite 来对数据库实现CRUD, 开发环境 VS2013, 1.1 在网上找到了 LINQ to DB T4 Models, 配置参考网址链接: http://www. ...

  3. MVC返回图片

    这几天忙着一些小事,也没有写什么了,今天,我们来玩一个比较简单的东东.就是在MVC下如何返回图片,相信,在传统WebForm下,大家都晓得怎么弄,方也不限于一种,但是,在架构较为严格的MVC里面,刚开 ...

  4. Python实现LR(逻辑回归)

    Python实现LR(逻辑回归) 运行环境 Pyhton3 numpy(科学计算包) matplotlib(画图所需,不画图可不必) 计算过程 st=>start: 开始 e=>end o ...

  5. SQL SERVER定时任务执行跟踪--供远程查看 [原创]

    一.背景 每次查需要优化的SQL都需要上外网,通过Profiler,报表或者DMV执行特定sql来查找,来回跑很麻烦,能不能在本地直接监控外网的好性能的SQL呢?方法是有的,我们可以通过把Profil ...

  6. [收藏]win8安装弹出输入的产品密钥与用于安装任何可用windows映像都不匹配

    问题描述: 帮朋友装win8(第一次装大神不要喷我啊)结果到 现在安装 这一步的时候 点击 现在安装 弹出个窗口 说输入的产品密钥与用于安装任何可用windows映像都不匹配.请输入其他产品密钥 解决 ...

  7. android ViewPaper高度自适应

    tv_btn_web.measure(0, 0);//计算所需的真实宽高 LayoutParams params=vp_btn_menu.getLayoutParams(); params.heigh ...

  8. android 开发怎么让程序生成的图片文件不会被系统扫描到

    我们在写应用的时候,可能会保存很多图片,大的小的,仅仅是我们的应用中会用到,处于种种原因不希望用户看到,我是觉着如果被用户看到了,就失去了我的应用的那一层神秘的面纱,用户是米有闲情逸致去打开你一层层的 ...

  9. jsp或Action获取请求参数中文乱码

    普通情况下,中文字符会被自动转换成iso-8859-1的编码格式通过网络传输,而这种格式是没办法直接表示出我们认识的中文字符的,所以还要手动将他转换回之前的字符集. 一般在servlet或者actio ...

  10. Netsharp快速入门(之3) 基础档案(之B 实体建模 新建项目)

    作者:秋时 杨昶   时间:2014-02-15  转载须说明出处 3.3     创建业务模型 3.3.1  新建项目 1.打开业务模型 2.打开业务模型后,在工具栏上选择操作-新增项目分类,标识这 ...