题解 | #坐标移动#

坐标移动

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

import sys

s = ""
for line in sys.stdin:
    a = line.split()
    s = a[0]
l = s.split(";")
point = [0, 0]
for i in l:
    if not i:
        continue
    elif i[0] == "X":
        continue
    elif len(i)>3:
        continue
    elif i[0]=="A" and i[1:].isdigit():
        point[0] = point[0] - int(i[1:])
    elif i[0]=="D" and i[1:].isdigit():
        point[0] = point[0] + int(i[1:])
    elif i[0]=="W" and i[1:].isdigit():
        point[1] = point[1] + int(i[1:])
    elif i[0]=="S" and i[1:].isdigit():
        point[1] = point[1] - int(i[1:])
    else:
        continue
print(str(point[0])+","+str(point[1]))



全部评论

相关推荐

榕城小榕树:1200单休,我去干点啥别的不好
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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