解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(), n = scanner.nextInt(); int[][] a = new int[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { a[i][j] = scanner.nextInt(); } } int x = scanner.nextInt(), y = scanner.nextInt(); String s = scanner.next(); int k = scanner.nextInt(); for (int i = 0; i < k; i++) { if (a[x][y] == 0) { a[x][y] = 1; switch (s.charAt(0)) { case 'U': s = "L"; y--; break; case 'D': s = "R"; y++; break; case 'L': s = "D"; x++; break; case 'R': s = "U"; x--; break; } } else { a[x][y] = 0; switch (s.charAt(0)) { case 'U': s = "R"; y++; break; case 'D': s = "L"; y--; break; case 'L': s = "U"; x--; break; case 'R': s = "D"; x++; break; } } } System.out.println(x+" "+y); } }
0.0分
2 人评分
震宇大神的杀毒软件 (C语言代码)浏览:1348 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:770 |
简单的a+b (C语言代码)浏览:594 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1550 |
十->二进制转换 (C语言代码)浏览:1330 |
C语言程序设计教程(第三版)课后习题6.6 (C++代码)浏览:649 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:366 |
DNA (C语言代码)浏览:564 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:541 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:438 |