解法
坐标移动
http://www.nowcoder.com/questionTerminal/119bcca3befb405fbe58abe9c532eb29
import java.util.*; class Point{ public int x; public int y; public Point(int x,int y){ this.x=x; this.y=y; } } public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); String[] arr = scan.next().split("\\;+"); Point now=new Point(0,0); for(int i=0;i<arr.length;i++){ if(isValid(arr[i])){ char ch=arr[i].charAt(0); int num=Integer.valueOf(arr[i].substring(1)); if(ch=='A'){ now.x-=num; }else if(ch=='D'){ now.x+=num; }else if(ch=='W'){ now.y+=num; }else if(ch=='S'){ now.y-=num; } } } System.out.println(now.x+","+now.y); } public static boolean isValid(String str){ char ch=str.charAt(0); if(ch=='A'||ch=='D'||ch=='W'||ch=='S'){ str=str.substring(1); for(int i=0;i<str.length();i++){ if(!Character.isDigit(str.charAt(i))){ return false; } } return true; }else{ return false; } } }