题解 | 坐标移动

坐标移动

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

import sys
s=input()
arr=s.split(';')
x,y=0,0
for w in arr:
    try:
        d=int(w[1:])
    except Exception:
        continue
    if w[0]=='A':
        x-=d
    elif w[0]=='D':
        x+=d
    elif w[0]=='W':
        y+=d
    elif w[0]=='S':
        y-=d
print(f'{x},{y}')

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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