/*
思路: 总体是字符串处理。 注意输入数据的获取
1. 使用 getline(cin, str, ';') 来获取输入数据。 使用 pair<int, int> 来表示坐标
2. 判断获取到的输入数据是否满足要求。 a. 判空 b. 数字是否符合要求
3. 对获取到的字符串第一个字符做switch 判断。
4. 根据不同的 case , 坐标做相应的移到
*/
#include <cctype>
#include<iostream>
#include <utility>
using namespace std;
bool checkIsNum(string str){
bool bisNum = true;
for(auto c : str){
if(!isdigit(c)){
bisNum = false;
break;
}
}
return bisNum;
}
int main(){
string str;
string num;
bool bisNum = false;
pair<int, int> pos(0,0);
while(getline(cin, str, ';')){
if(str.empty()){
continue;
}
num = str.substr(1);
bisNum = checkIsNum(num);
if(bisNum){
switch (str[0]) {
case 'W':
pos.second += stoi(num);
break;
case 'S':
pos.second -= stoi(num);
break;
case 'A':
pos.first -= stoi(num);
break;
case 'D':
pos.first += stoi(num);
break;
default:
break;
}
}
}
cout << pos.first << ',' << pos.second << endl;
return 0;
}