本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
X 星球的一处迷宫游乐场建在某个小山坡上。它是由 10×10 相互连通的小房间组成的。
房间的地板上写着一个很大的字母。我们假设玩家是面朝上坡的方向站立,则:
X 星球的居民有点懒,不愿意费力思考。他们更喜欢玩运气类的游戏。这个游戏也是如此!
开始的时候,直升机把 100 名玩家放入一个个小房间内。玩家一定要按照地上的字母移动。
迷宫地图如下:
UDDLUULRUL
UURLLLRRRU
RRUURLDLRD
RUDDDDUUUU
URUDLLRRUU
DURLRLDLRL
ULLURLLRDU
RDLULLRDDD
UUDDUDUDLL
ULRDLUURRR
请你计算一下,最后,有多少玩家会走出迷宫,而不是在里边兜圈子?
如果你还没明白游戏规则,可以参看下面一个简化的 4x4 迷宫的解说图:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int ans=0;
char[][] ch=new char[][]{{'0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','U','D','D','L','U','U','L','R','U','L','0'},
{'0','U','U','R','L','L','L','R','R','R','U','0'},
{'0','R','R','U','U','R','L','D','L','R','D','0'},
{'0','R','U','D','D','D','D','U','U','U','U','0'},
{'0','U','R','U','D','L','L','R','R','U','U','0'},
{'0','D','U','R','L','R','L','D','L','R','L','0'},
{'0','U','L','L','U','R','L','L','R','D','U','0'},
{'0','R','D','L','U','L','L','R','D','D','D','0'},
{'0','U','U','D','D','U','D','U','D','L','L','0'},
{'0','U','L','R','D','L','U','U','R','R','R','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0'}};
for(int i=1;i