题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
l = list(input().strip().split(';'))
x, y = 0, 0
for s in l:
if not 2 <= len(s) <= 3:
continue
if len(s) > 1 and s[0] in ['A', 'D', 'W', 'S']:
if all(i in '0123456789' for i in s[1:]):
step = int(s[1:])
if s[0] == 'A': x -= step
elif s[0] == 'D': x += step
elif s[0] == 'W': y += step
elif s[0] == 'S': y -= step
print('{},{}'.format(x, y))
查看8道真题和解析
科大讯飞公司氛围 477人发布