#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. C 的 一些写法格式 交流

    好久以前刚开始学习前辈们的代码的时候,发现好多代码感到好奇怪. 1)代码看不懂 2)代码格式看不懂 网上也没见同学们分享.当自己代码写多了,也渐渐的理解为什么要这样写了. 说主题之前 还是 说一些 题 ...

  2. 10 款提高开发效率的 jQuery/CSS3 组件

    前端开发是一项十分繁琐而又耗体力的工作,如何更有效率的开发我们的应用,很多人会选择适当地使用一些jQuery插件.今天就要给大家分享10款可以提高开发效率的jQuery/CSS3组件.部分插件可以下载 ...

  3. Linux下使用Magent+Memcached缓存服务器集群部署

    1.编译安装libevent  cd /root/soft_hhf/  wget http://cloud.github.com/downloads/libevent/libevent/libeven ...

  4. spring aop 使用注解方式总结

    spring aop的注解方式:和xml的配置方式略有区别,详细如下: 1.首先还是建立需要的切面类:切面类里面定义好切点配置,以及所有的需要实现的通知方法. /** * */ package com ...

  5. db2查询锁表

    --查询锁表情况,可以获取哪个表被锁,其中agent_id为哪个DB2进程锁了表(db2inst1用户下) select * from sysibmadm.LOCKS_HELD with ur; -- ...

  6. hdu 2066 一个人的旅行

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2066 一个人的旅行 Description 虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷 ...

  7. Golang之AES/DES加密解密

    AES/DES加密/解密涉及4个概念:1. Block, 也叫分组, 相应加密/解密的算法. 2. BlockMode, 模式, 相应加密/解密的处理.3. InitalVectory, 初始向量4. ...

  8. 在C#使用文件监控对象FileSystemWatcher的几种方案

    最近在项目中有这么个需求,就是得去实时获取某个在无规律改变的文本文件中的内容.首先想到的是用程序定期去访问这个文件,因为对实时性要求很高,间隔不能超过1S,而且每次获取到文本内容都要去分发给web服务 ...

  9. AMD 和 CMD as lazy as possible

    http://blog.chinaunix.net/uid-26672038-id-4112229.html AMD 与 CMD 区别到底在哪里?       看了以上 AMD,requireJS 与 ...

  10. iOS学习之UIScrollView

    一.UIScrollView的创建和常用属性      1.UIScrollView概述 UIScrollView是UIView的子类. UIScrollView作为所有滚动视图的基类. UIScro ...