题解 | #坐标移动#

坐标移动

https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29

#include <vector>
#include <iostream>
using namespace std;

int main() {
    string a;
    cin >> a;
    int x=0;
    int y=0;
    char c;
    int d=0;
    string s;
    string l;
    vector<string> v;
    int cn=0;
    for(auto e : a){
        if(e != ';'){
            s = s+e;
        } else {
            if(s != ""){
            v.push_back(s);
            }
            s = "";
        }   
    }
    int f=0;
    for(auto e : v){
        for(int i=0;i<e.size();i++){
            if('a' <= e[i] && e[i] <= 'z' || 'A' <=  e[i] && e[i] <= 'Z'){
                c = e[i];
                cn++;
                if(cn == 2){
                    f=1;
                    break;
                }
            }else if('0' <= e[i] && e[i] <= '9'){
                d = d*10 + e[i] - 48;
                //cout << "d" << d << endl;
            }else{
                f=1;
                break;
            }
        }
        cn =0;
        //cout << c << d << endl;
        if(f != 1){
            if(c == 'A'){
                x = x-d;
            }else if(c == 'D'){
                x=x+d;
            }else if(c == 'S'){
                y=y-d;
            }else if(c == 'W'){
                y=y+d;
            }
        }
        f =0;
        d =0;
        c = ' ';
       // cout << x << "," << y << endl;
    }
    cout << x << "," << y << endl;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

Southyeung:我说一下我的看法(有冒犯实属抱歉):(1)简历不太美观,给我一种看都不想看的感觉,感觉字体还是排版问题;(2)numpy就一个基础包,机器学习算法是什么鬼?我感觉你把svm那些写上去都要好一点。(2)课程不要写,没人看,换成获奖经历;(3)项目太少了,至少2-3个,是在不行把网上学习的也写上去。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务