题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
s=input().split(';')
x=0;y=0
for i in s:
if 2<=len(i)<=3 and i[0].isupper() and i[1:].isdigit():
d=int(i[1:])
if 'A'in i:
x-=d
elif 'D' in i:
x+=d
elif 'S' in i:
y-=d
elif 'W' in i:
y+=d
print(str(x)+','+str(y))

查看1道真题和解析