题解 | #坐标移动#

坐标移动

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

s=input().split(';')
a=[0,0]
for i in s:
    try:
        if i[0] in ['A','S','W','D']:
            step=int(i[1::])
            if i[0]=='A':
                a[0]-=step
            elif i[0]=='S':
                a[1]-=step
            elif i[0]=='W':
                a[1]+=step
            elif i[0]=='D':
                a[0]+=step
    except:
        continue
print(str(a[0])  +','+ str(a[1]))


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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