参考代码:
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class T1522 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner=new Scanner(System.in); int T=scanner.nextInt(); List<String> list=new ArrayList<String>(); for (int i = 0; i < T; i++) { int N=scanner.nextInt(); char num[][]=new char[N][N]; int x=0,y=0; for (int j = 0; j < num.length; j++) { String str=scanner.next(); for (int j2 = 0; j2 < num[j].length; j2++) { num[j][j2]=str.charAt(j2); if (num[j][j2]=='S') { x=j; y=j2; } } } int Q=scanner.nextInt(); for (int j = 0; j < Q; j++) { String s=scanner.next(); int x1=x; int y1=y; for (int k = 0; k < s.length(); k++) { if (s.charAt(k)=='L') { y1--; } else if(s.charAt(k)=='R'){ y1++; } else if (s.charAt(k)=='U') { x1--; } else if (s.charAt(k)=='D') { x1++; } String jg=""; if (x1<0||x1>=num.length||y1<0||y1>=num[0].length) { list.add("I am out!"); break; } else if (num[x1][y1]=='#') { list.add("I am dizzy!"); break; } else if (num[x1][y1]=='T') { list.add("I get there!"); break; } else if (k==s.length()-1&&num[x1][y1]!='T') { list.add("I have no idea!"); break; } } } } for (String str: list) { System.out.println(str); } } }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:998 |
A+B for Input-Output Practice (III) (C语言代码)浏览:592 |
哥德巴赫曾猜测 (C语言代码)浏览:2560 |
1908题解浏览:680 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:569 |
蚂蚁感冒 (C语言代码)浏览:816 |
C语言训练-亲密数 (C语言描述,反正怎么都能对)浏览:2256 |
第三届阿里中间件性能挑战赛-总决赛亚军比赛攻略浏览:1170 |
printf基础练习 (C语言代码)浏览:2268 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:620 |