解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class A1429 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int m = sc.nextInt();
int n = sc.nextInt();
int [][]arr= new int[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
arr[i][j]=sc.nextInt();
}
}
int x =sc.nextInt();
int y =sc.nextInt();
String s = sc.next();
int k = sc.nextInt();
int a = 0;
switch (s) {
case "U":a=1000;
break;
case "R":a=1001;
break;
case "D":a=1002;
break;
case "L":a=1003;
break;
default:
break;
}
for (int i = 0; i < k; i++) {
if(arr[x][y]==1) {
a++;
arr[x][y]=0;
}else {
a--;
arr[x][y]=1;
}
switch (a%4) {
case 0:
x--;
break;
case 1:
y++;
break;
case 2:
x++;
break;
case 3:
y--;
break;
default:
break;
}
}
System.out.println(x+" "+y);
}
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:641 |
C语言训练-数字母 (C语言代码)浏览:640 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:575 |
【亲和数】 (C语言代码)浏览:624 |
大家好,我是验题君浏览:595 |
矩阵乘方 (C语言代码)浏览:1071 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:752 |
C二级辅导-公约公倍 (C语言代码)浏览:532 |
一元一次方程 (C语言代码)浏览:4186 |
图形输出 (C语言代码)浏览:1011 |