题解 | 坐标移动
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import sys
import re
m=list(input().split(';'))
x,y=0,0
for step in m:
if re.fullmatch(r'([ADWS]{1})(\d+)',step):
d=step[0]
s=int(step[1:])
if 0<s<100:
if d == 'A':
x=x-s
elif d == 'D':
x=x+s
elif d == 'W':
y=y+s
elif d == 'S':
y=y-s
print('{},{}'.format(x,y))
查看11道真题和解析