#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. shell字符串的截取

    1.变量 var 从 npos ∈ [0, length-1] 位开始,从左->右截取 num 个字符: ${var:npos:num} / ${var:npos} 小结:若 npos < ...

  2. shelll函数求两个输入数字之和

    #!/bin/bash #This is a test of the addition of the program! function AddFun { read -p "Enter a ...

  3. 使用angular封装echarts

    Echarts是一个开源的图表组件,图表比较丰富,工作中需要用到它来搭建一个数据展示系统.但是系统原有的框架是基于angular的,而echarts是基于原生js的,如果直接使用的话就丢失了angul ...

  4. mongoDB 3.0 安全权限访问控制

    MongoDB3.0权限,啥都不说了,谷歌百度出来的全是错的.先安装好盲沟,简单的没法说. 首先,不使用 —auth 参数,启动 mongoDB: mongodb-linux-i686-3.0.0/b ...

  5. PHP调用WEBSERVICE接口常见问题答疑以及总结

    最近的工作项目中,接触到了很多的政府 微信开发项目.对方的外包公司都是使用JAVA作为开发语言,然后通过WEBSERVICE进行接口返回数据到我的项目中.一般情况下,能在浏览器打开并显示数据的接口是直 ...

  6. ExtJS MVC 学习手记3

    在演示应用中,我们已经创建好了viewport,并为之添加了一个菜单树.但也仅仅是这样,点击树或应用的其他地方获得不到任何响应.这个演示应用还是一个死的应用. 接下来,我们让这个应用活起来. 首先,给 ...

  7. layer 弹出子页面然后给父页面赋值

    //----赋值 并关闭当前页面 开始---- FunctionActionDeleteXZ = function (CompanyId, RelCompanyName) { parent.$(&qu ...

  8. SVN补充

    为什么使用SVN? 1.需求1:备份,以防电脑死机断电等 2.需求2:代码还原,代码不管你改成什么样都可以找到某一段的版本 3.需求3:协同修改,下载修改同一个文件,防止被相互覆盖 4.需求4:多版本 ...

  9. hasOwnProperty与isPrototypeOf

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 向Array中添加希尔排序

    希尔排序思路 我们在第 i 次时取gap = n/(2的i次方),然后将数组分为gap组(从下标0开始,每相邻的gap个元素为一组),接下来我们对每一组进行直接插入排序. 希尔排序实现 Functio ...