import java.util.ArrayList;
import java.util.Scanner;
public class Main{
public static ArrayList<String> list=new ArrayList<String>();
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while (t-->0) {
sc.nextLine();
int n=sc.nextInt();
char arr[][]=new char[n][n];
int x=0,y=0;
for (int i = 0; i < n; i++) {//输入
String str=sc.next();
for (int j = 0; j <str.length(); j++) {
arr[i][j]=str.charAt(j);
if (arr[i][j]=='S') {
x=i;
y=j;
}
}
}
int m=sc.nextInt();//指令条数
for (int i = 0; i < m; i++) {
//直接判断指令,且输出答案
String ZhiLin=sc.next();
name(arr, ZhiLin, x, y);
}
}
//输出结果
for (String item : list) {
System.out.println(item);
}
}
//判断指令,返回结果
public static void name(char arr[][],String Zhi,int x,int y) {
for (int i = 0; i <Zhi.length(); i++) {
char c=Zhi.charAt(i);
if (c=='R') {
y++;
}if (c=='U') {
x--;
}if (c=='L') {
y--;
}if (c=='D') {
x++;
}
//判断位置
if (x<0 || y<0 || x>=arr.length || y>=arr[0].length) {
list.add("I am out!");
return ;//退出
}else if(arr[x][y]=='#'){
list.add("I am dizzy!");
return ;
}else if (arr[x][y]=='T') {
list.add("I get there!");
return ;
}
}
//未能到达终点
list.add("I have no idea!");
//return ; 不能加return,加了不能通过。
}
}-------------------------
这个return可有可无,并且在我的电脑上测试样例可以通过。
但提交后无法通过。

0.0分
1 人评分
C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:
一点编程也不会写的:零基础C语言学练课程
解决困扰你多年的C语言疑难杂症特性的C语言进阶课程
从零到写出一个爬虫的Python编程课程
只会语法写不出代码?手把手带你写100个编程真题的编程百练课程
信息学奥赛或C++选手的 必学C++课程
蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程
手把手讲解近五年真题的蓝桥杯辅导课程
发表评论 取消回复