HDOJ1035 ( Robot Motion ) 【递归】

简介:
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
复制代码
 1 #include <stdio.h>
 2 int maze[11][11];
 3 int r,c,b;
 4 int idx;
 5 void step(int x,int y)
 6 {
 7     int t;
 8     if(x<0||x>=r||y<0||y>=c)
 9     {
10         printf("%d step(s) to exit\n",idx-999);
11         return;
12     }
13     if(maze[x][y]>=1000)
14     {
15         printf("%d step(s) before a loop of %d step(s)\n",maze[x][y]-1000,idx-maze[x][y]+1);
16         return;
17     }
18     t=maze[x][y];
19     idx++;
20     maze[x][y]=idx;
21     switch (t)
22     {
23     case 'N':
24         step(x-1,y);
25         break;
26     case 'S':
27         step(x+1,y);
28         break;
29     case 'E':
30         step(x,y+1);
31         break;
32     case 'W':
33         step(x,y-1);
34         break;
35     }
36 }
37 int main()
38 {
39     int i,j;
40     while (scanf("%d%d",&r,&c),r||c)
41     {
42         scanf("%d",&b);
43         getchar();
44         for (i=0;i<r;i++)
45         {
46             for (j=0;j<c;j++)
47                 maze[i][j]=getchar();
48             getchar();
49         }
50         idx=999;
51         step(0,b-1);
52     }
53     return 0;
54 }
复制代码

 

本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/05/11/2495831.html,如需转载请自行联系原作者

相关文章
|
机器人 定位技术
HDU-1035,Robot Motion(DFS+模拟)
HDU-1035,Robot Motion(DFS+模拟)
|
机器人
HDU-1035,Robot Motion(DFS)
HDU-1035,Robot Motion(DFS)
|
机器人
hdu1035 Robot Motion(简单模拟题)
hdu1035 Robot Motion(简单模拟题)
54 0
|
机器学习/深度学习 数据挖掘
|
机器学习/深度学习 自然语言处理 算法
TPLinker: Single-stage Joint Extraction of Entities and Relations Through Token Pair Linking 论文解读
近年来,从非结构化文本中提取实体和关系引起了越来越多的关注,但由于识别共享实体的重叠关系存在内在困难,因此仍然具有挑战性。先前的研究表明,联合学习可以显著提高性能。然而,它们通常涉及连续的相互关联的步骤,并存在暴露偏差的问题。
240 0
|
传感器 机器人
robot_pose_ekf运行报错问题解决
robot_pose_ekf运行报错问题解决
robot_pose_ekf运行报错问题解决
|
机器人 C++
Codeforces 626A Robot Sequence(模拟)
A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard out...
999 0
|
API Java 安全
Building the JavaCall Porting Layer (phoneME Feature MR4)
Building the JavaCall Porting Layer (phoneME Feature MR4)   The JavaCall porting layer provides a uniform set o...
692 0
A+B for Input-Output Practice (VII)
http://acm.hdu.edu.cn/showproblem.php?pid=1095  Problem DescriptionYour task is to Calculate a + b.InputThe input will consist of a series of pairs o...
984 0

热门文章

最新文章