题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
location = [0,0]
for i in input().split(';'):
if len(i)<=3:
try:
if i[0]=='A':
location[0] -= int(i[1::])
elif i[0]=='D':
location[0] += int(i[1:])
elif i[0]=='W':
location[1] += int(i[1:])
elif i[0]=='S':
location[1] -= int(i[1:])
except:
continue
print(f'{location[0]},{location[1]}')

查看10道真题和解析