题解 | #坐标移动#

坐标移动

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

x,y = 0,0
lst = input().split(';')
for s in lst:
    if len(s) in [2,3]:
        try:
            dis = int(s[1:])
        except:
            continue
        if s[0]=='A':
            x -= dis
        elif s[0]=='D':
            x += dis
        elif s[0]=='W':
            y += dis
        elif s[0] == 'S':
            y -= dis
print(x,end=',')
print(y)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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