题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
inStr = input()
inList = inStr.split(";")
x = 0
y = 0
for item in inList:
    if 2 <= len(item) < 4:
        if item[0].isalpha() and item[1:].isdigit():
            if item[0] == "A":
                x = x - int(item[1:])
            elif item[0] == "D":
                x = x + int(item[1:])
            elif item[0] == "W":
                y = y + int(item[1:])
            elif item[0] == "S":
                y = y - int(item[1:])
    
print(f'{x},{y}')

查看15道真题和解析