题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x =0;
    int y =0;
    int xflag =1;
    int yflag =1;
    string str ;
    string str1;
    string str2;
    cin >> str;
    vector<string> v;
    for(auto c:str){
          if(c==';'){
            v.push_back(str1);
            str1.resize(0,'0');
            continue;
          }
          else{
            str1+=c;
          }
    }
    for(int i=0;i<v.size();i++){
        str2.resize(0);
        int count = 0;
        int n=0;
        xflag =1;
        yflag =1;
        for(auto c: v[i]){
            if(c=='A'||c=='S'||c=='W'||c=='D'){
               count++;
            }
        }   
        for(auto h: v[i]){
            if(count!=1||v[i][0]!='A'&&v[i][0]!='S'&&v[i][0]!='W'&&v[i][0]!='D'){
            break;
           }
            if(h=='A'){
                xflag = -1;
                yflag = 0;
                continue;
            }
            if(h=='S'){
                yflag = -1;
                xflag = 0;
                continue;
            }
            if(h=='W'){
                xflag =0;
                continue;
            }
            if(h=='D'){
                yflag=0;
                continue;
            }
            str2+=h;
            n++;
        }
        if(str2.size()){
        x+=(stoi(str2))*xflag;
        y+=(stoi(str2))*yflag;
        }
    }
    cout << x << ',' << y << endl; 
}
// 64 位输出请用 printf("%lld")
 投递东软集团等公司10个岗位
投递东软集团等公司10个岗位
