题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
str1 = input()
str1 = str1.split(";")
start = [0,0]
for i in range(len(str1)):
if len(str1[i]) > 3 or len(str1[i]) <= 1 or str1[i][2:3].isalpha() or str1[i][1:2].isalpha():
continue
else:
oper, step = str1[i][0:1], int(str1[i][1:])
if oper == 'A':
start = [start[0]-step,start[1]]
elif oper == 'D':
start = [start[0]+step,start[1]]
elif oper == 'S':
start = [start[0], start[1]-step]
elif oper == 'W':
start = [start[0], start[1] + step]
else:
continue
print(",".join(str(i) for i in start))
简单且暴力的方法
海康威视公司福利 1182人发布
查看10道真题和解析