pos = [0, 0]
while True:
s = input()
if not s:
break
if s == "stop":
break
movement = s.split(" ")
direction = movement[0]
steps = int(movement[1])
if direction == "up":
pos[0] += steps
elif direction == "down":
pos[0] -= steps
elif direction == "left":
pos[1] -= steps
elif direction == "right":
pos[1] += steps
else:
pass
print(int(round(math.sqrt(pos[1] ** 2 + pos[0] ** 2))))
python计算机器人停止移动时与原点的距离
最新推荐文章于 2023-04-27 14:52:03 发布