题解 | #字符串排序#

坐标移动

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

s = input()
s_list = s.split(";")
point = [0, 0]
for i in s_list:
    if len(i) >= 2:
        if i[0] == "A" and i[1:len(i)].isdigit():
            point[0] = point[0]-int(i[1:len(i)])
        elif i[0] == "D" and i[1:len(i)].isdigit():
            point[0] = point[0]+int(i[1:len(i)])
        elif i[0] == "W" and i[1:len(i)].isdigit():
            point[1] = point[1]+int(i[1:len(i)])
        elif i[0] == "S" and i[1:len(i)].isdigit():
            point[1] = point[1]-int(i[1:len(i)])
print(str(point[0])+","+str(point[1]))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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