题解 | #坐标移动#正则匹配
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
int x = 0, y = 0;
String[] a = s.split(";");
for(int i=0;i<a.length;i++) {
if(a[i].matches("A\\d{1,2}")){
x-=Integer.parseInt(a[i].substring(1));
}else if(a[i].matches("W\\d{1,2}")) y+=Integer.parseInt(a[i].substring(1));
else if(a[i].matches("D\\d{1,2}")) x+=Integer.parseInt(a[i].substring(1));
else if(a[i].matches("S\\d{1,2}")) y-=Integer.parseInt(a[i].substring(1));
}
System.out.println(x + "," + y);
}
}

