题解 | #坐标移动# Python3:模拟
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
if __name__ == '__main__':
steps = list(input().strip().split(';'))
x, y = 0, 0
for step in steps:
if len(step) < 1: continue
direction = step[0]
dist = step[1:]
if not dist.isnumeric(): continue
dist = int(dist)
if direction == 'A':
x = x - dist
elif direction == 'D':
x = x + dist
elif direction == 'W':
y = y + dist
elif direction == 'S':
y = y - dist
print(','.join(map(str, [x, y])))
#23届找工作求助阵地##软件开发薪资爆料##我的实习求职记录##你们的毕业论文什么进度了#算法之路 文章被收录于专栏
有关数据结构、算法等的文章
基恩士成长空间 439人发布
