解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { static int x = 0; static int y = 0; private static void f(int d) { if (d == 0) { x--; } else if (d == 1) y++; else if (d == 2) x++; else { y--; } } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); int n = scanner.nextInt(); int a[][] = new int[m][n]; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { a[i][j] = scanner.nextInt(); } } x = scanner.nextInt(); y = scanner.nextInt(); char c = scanner.next().charAt(0); int d = 0; if (c == 'R') d = 1; else if (c == 'D') d = 2; else if (c == 'L') d = 3; int t = scanner.nextInt(); for (int i = 0; i < t; i++) { if (a[x][y] == 0) { a[x][y] = 1; d = (d + 4 - 1) % 4; f(d); } else { a[x][y] = 0; d = (d + 1) % 4; f(d); } } System.out.println(x + " " + y); } }
0.0分
0 人评分
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1368 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:503 |
图形输出 (C语言代码)浏览:1422 |
Hello, world! (C语言代码)浏览:916 |
淘淘的名单 (C语言代码)浏览:1309 |
陶陶摘苹果2 (C语言代码)浏览:650 |
众数问题 (C语言代码)浏览:717 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:751 |
小O的数字 (C语言代码)浏览:1490 |
幸运数 (C++代码)浏览:2982 |