#include <iostream>
#include <string>
#include <vector>
using namespace std;
/*
思路:从输入字符串查找分号‘;’, 将分号前部分字符串存入动态数组vector<string>, 情况临时字符串,根据ADWS进行左右上下移动
*/
void CoordinateStr1(string strIn, int &x, int &y)
{
int strInLen = strIn.length();
vector<string> vec;
string strTemp;
bool flag = false;
for(int i = 0; i < strInLen; i++) {
if(strIn[i] = ';') {
if((strTemp.size() == 3 && strTemp.at(1) >= '0' && strTemp.at(1) <= '9'
&& strTemp.at(2) >= '0' && strTemp.at(2) <= '9') ||
(strTemp.size() == 2 && strTemp.at(1) >= '0' && strTemp.at(1) <= '9')) {
vec.push_back(strTemp);
strTemp.clear();
}
} else {
strTemp += strIn[i];
}
}
for(int i = 0; i < vec.size(); i++) {
string strTemp = vec[i];
int strTempLen = vec[i].length();
if(strTemp[0] == 'A') {
x -= stoi(strTemp.substr(1, strTempLen));
} else if(strTemp[0] == 'D') {
x += stoi(strTemp.substr(1, strTempLen));
} else if(strTemp[0] == 'W') {
y += stoi(strTemp.substr(1, strTempLen));
} else if(strTemp[0] == 'S') {
y -= stoi(strTemp.substr(1, strTempLen));
}
}
return;
}
/*
思路:通道find()查找分号‘;’,获取索引,根据索引获取字符串,再根据ADWS进行左右上下移动;
输出条件是到字符结束符npos
*/
void CoordinateStr2(string strIn, int &x, int &y)
{
int strInLen = strIn.length();
while(1) {
/*
npos是一个常数,用来表示不存在的位置,string::npos代表字符串到头了结束了。
npos 是这样定义的:
static const size_type npos = -1;
*/
if(strIn.find(';') == std::string::npos) {
break;
}
int index = strIn.find(';');
string strTemp = strIn.substr(0, (index - 0));
if((strTemp.size() == 3 && strTemp.at(1) >= '0' && strTemp.at(1) <= '9'
&& strTemp.at(2) >= '0' && strTemp.at(2) <= '9') ||
(strTemp.size() == 2 && strTemp.at(1) >= '0' && strTemp.at(1) <= '9')){
switch(strTemp.at(0)) {
case 'A' :
x -= stoi(strTemp.substr(1));
break;
case 'D' :
x += stoi(strTemp.substr(1));
break;
case 'W' :
y += stoi(strTemp.substr(1));
break;
case 'S' :
y -= stoi(strTemp.substr(1));
break;
default:
break;
}
}
strIn = strIn.substr(index+1);
}
return;
}
int main()
{
string strIn;
int x = 0;
int y = 0;
while(cin>>strIn) {
//CoordinateStr1(strIn, x, y);
CoordinateStr2(strIn, x, y);
cout<<x<<','<<y<<endl;
}
}