解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class T1429 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { int row = in.nextInt(),col = in.nextInt(); int [][]a = new int[row][col]; for(int i = 0;i<row;i++) for(int j = 0;j<col;j++) a[i][j]=in.nextInt(); int x = in.nextInt(),y = in.nextInt(); char dir = in.next().charAt(0); int steps = in.nextInt(); //solve String str = "LURD"; int [][][]t = {{{0,-1},{-1,0},{0,1},{1,0}}, {{0,-1},{-1,0},{0,1},{1,0}}}; int []t2 = {3,1}; while(steps-->0) { dir=str.charAt((str.indexOf(dir)+t2[a[x][y]])%4); a[x][y]=(a[x][y]+1)%2; x+=t[a[x][y]][str.indexOf(dir)][0]; y+=t[a[x][y]][str.indexOf(dir)][1]; } System.out.println(x+" "+y); } in.close(); } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:482 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:628 |
程序员的表白 (C语言代码)浏览:1319 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:494 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:645 |
九宫重排 (C++代码)浏览:2160 |
简单的a+b (C++语言代码)浏览:853 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:677 |
WU-字符串比较 (C++代码)浏览:755 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:703 |