#include <iostream> #include <vector> #include <string> using namespace std; int main() { string str; while(getline(cin,str)) { int x = 0,y = 0; int size = str.size(); if(size == 0){ return 0; }//if vector<string> vec; int start = 0,end = 0; // 把两个分号之间的内容提取出来 while(end != -1) { end = str.find(";",start); vec.push_back(str.substr(start,end-start)); start = end+1; }//while // 坐标移动 int count = vec.size(); for(int i = 0;i < count;++i) { string word = vec[i]; int len = word.size(); if(len < 1 || len > 3) { continue; }//if if(word[0] == 'A' || word[0] == 'D' || word[0] == 'W' || word[0] == 'S') { int num = 0; bool flag = true; // 计算移动的距离 for(int j = 1;j < len;++j) { if(word[j] < '0' || word[j] > '9') { flag = false; break; }//if num = num * 10 + word[j] - '0'; }//for // 移动距离非法 if(!flag) { continue; }//if if(word[0] == 'A') { x -= num; }//if else if(word[0] == 'D') { x += num; }//else else if(word[0] == 'W') { y += num; }//else else if(word[0] == 'S') { y -= num; }//else }//if }//for cout<<x<<","<<y<<endl; } return 0; } </string></string></vector></iostream>