void move(string &str, int &x, int &y)
{
if (str.empty()){
return;
}
string::size_type beg, end;
beg = 0;
while (beg != str.size())
{
end = str.find_first_of(';',beg);
if (beg != end)//不是空,不是只有一个分号的话,继续判断输入是否合法
{
char direction = str[beg];
int value = 0;
if (direction == 'A' || direction == 'W' || direction == 'D' || direction == 'S')//第一个字符合法
{
bool isdig = true;
for (size_t i = beg + 1; i != end; i++){//第一个字符合法的情况下判断后面的字符是不是数字
if (!isdigit(str[i])){
isdig = false;
break;
}
}
if (isdig)//后面的字符也是合法的话,就进行处理。否则进行下一个字符串的处理
{
string s(str, beg + 1, end - (beg + 1));
stringstream ss;
ss << s;
ss >> value;
switch(direction){
case 'A':
x = x - value;
break;
case 'D':
x = x + value;
break;
case 'W':
y = y + value;
break;
case 'S':
y = y - value;
break;
default:
break;
}
}
}
}
if (end != str.size())
{
beg = end + 1;
}
else {
beg = end;
}
}
}
int main(void){
string str;
int x, y;
x = 0;
y = 0;
while (cin >> str){
x = 0;
y = 0;
move(str, x, y);
cout << x << "," << y << endl;
}