题解 | #字符串排序#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
s = input()
s_list = s.split(";")
point = [0, 0]
for i in s_list:
if len(i) >= 2:
if i[0] == "A" and i[1:len(i)].isdigit():
point[0] = point[0]-int(i[1:len(i)])
elif i[0] == "D" and i[1:len(i)].isdigit():
point[0] = point[0]+int(i[1:len(i)])
elif i[0] == "W" and i[1:len(i)].isdigit():
point[1] = point[1]+int(i[1:len(i)])
elif i[0] == "S" and i[1:len(i)].isdigit():
point[1] = point[1]-int(i[1:len(i)])
print(str(point[0])+","+str(point[1]))
查看9道真题和解析