import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Step1 {
static List<Character> chs=new ArrayList<Character>();
static int x,y=0;
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str=reader.readLine();
chs.add('A');
chs.add('D');
chs.add('S');
chs.add('W');
//ADSW 0-99
//分离成数组,判断第一个字母所属,判断除第一个字母外是否为数字
//考虑分离基础
String[] strs=str.split(";");
for (int i = 0; i < strs.length; i++) {
if(strs[i].length()>=1){
jude(strs[i]);
}
}
System.out.println(x+","+y);
}
public static void jude(String str){
if(Step1.chs.contains(str.charAt(0))){
switch(str.charAt(0)){
case 'W':
y+= format(str);
break;
case 'S':
y-= format(str);
break;
case 'A':
x-= format(str);
break;
case 'D':
x+=format(str);
break;
}
}
}
public static int format(String str){
try{
int val = Integer.valueOf(str.substring(1));//异常点,数字转换异常
return val;
}catch (Exception e) {
}
return 0;
}
}
HJ17 坐标移动----牛客刷题
最新推荐文章于 2023-07-25 10:48:49 发布