题解 | #迷路的牛牛#

迷路的牛牛

http://www.nowcoder.com/practice/fc72d3493d7e4be883e931d507352a4a

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string str;
    cin>>str;
    int lcont=0,rcont=0;
    for(auto c:str){
        if(c=='L') lcont++;
        if(c=='R') rcont++;
    }
    int tmp = rcont-lcont;
    while(tmp<0) tmp+=4;
    while(tmp>=4) tmp%=4;
    string move = "NESW";
    cout<<move[tmp]<<endl;
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务