博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1204. Maze Traversal
阅读量:4452 次
发布时间:2019-06-07

本文共 2200 字,大约阅读时间需要 7 分钟。

1204.   Maze Traversal 

A common problem in artificial intelligence is negotiation of a maze. A maze has corridors and walls. The robot can proceed along corridors, but cannot go through walls.

Input

For this problem, you will input the dimensions of a maze, as two integer values on the first line. Of the two numbers, the first is the number of rows and the second is the number of columns. Neither the number of rows nor columns will exceed 60.

Following these numbers will be a number of rows, as specified previously. In each row there will be a character for each column, with the tow terminated by the end of line. Blank spaces are corridors, asterisks are walls. There needn't be any exits from the maze.

Following the maze, will be an initial row and column specified as two integers on one line. This gives the initial position of the robot. Initially the robot will be facing North (toward the first row).

The remaining input will consist of commands to the robot, with any amount of interspersed white-space. The valid commands are:

R rotate the robot 90 degrees clockwise (to the right)

L rotate the robot 90 degrees counter-clockwise (to the left)
F move the robot forward unless a wall prevents this in which case do nothing
Q quite the program, printing out the current robot row, column and orientation.

Output

The final row and column must be integers separated by a space. The orientation must be one of N, W, S, E and separated from the column by a space.

 

Sample Input

7 8********* * * *** *    ** * ** ** * *  **   * **********2 4RRFLFF FFRFFRFFQ

Sample Output

5 6 W 特别注意: 1、输入的行列号数跟数组内的下标数差一位,一定要注意转换。 2、读入字符串,特别是带有空白字符的字符串,一定还要注意回车符。 3、最后一定要注意输出最后一定要有一个回车符,不然会是PE错误,也就是输出格式错误。 printf("%d %d %c\n",robot.row+1,robot.col+1,robot.ori);
1 #include 
2 #include
3 4 int handle(char *ptr); 5 void move(char str); 6 7 8 struct R{ 9 int row;//行号 10 int col;//列号 11 char ori;//朝向 12 }robot; 13 char maze[60][60]; 14 15 int main(void) 16 { 17 int row,col,i,j; 18 char run[100]; 19 20 scanf("%d %d",&row,&col); 21 getchar(); 22 23 for(i=0;i

转载于:https://www.cnblogs.com/yushuo1990/p/4312329.html

你可能感兴趣的文章
《鬼谷子的局5》—— 读后总结
查看>>
记录安装oracle的那些事(二)之双系统安装
查看>>
c3po数据库连接池中取出连接
查看>>
bootstrap-table 分页
查看>>
使用本机IP调试web项目
查看>>
【bzoj1082】栅栏[SCOI2005]
查看>>
day18 Java学习(Map集合)
查看>>
Integer与int的区别
查看>>
hdu 1087
查看>>
LazyMan的Promise解法
查看>>
lua语言三则特性
查看>>
asp.net的Nelocity模板引擎
查看>>
fis webpack 原理对比
查看>>
22 广播的发送
查看>>
Linux 创建用户 限制SFTP用户只能访问某个目录
查看>>
正则表达式的学习笔记
查看>>
android图片特效处理之图片叠加
查看>>
结束贪心hdu 2491 Priest John's Busiest Day
查看>>
RHEL7中防火墙firewalld基础使用配置
查看>>
编程漫谈(八):此刻的幸福
查看>>