题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
opelist=input().split(';')
x,y=0,0
nums=[0.1,2,3,4,5,6,7,8,9]
for ope in opelist:
try:
if ope[0]=="A" and len(ope)<=3 and 0<=int(ope[1:])<=99:
x-=int(ope[1:])
elif ope[0]=="D" and len(ope)<=3 and 0<=int(ope[1:])<=99:
x+=int(ope[1:])
elif ope[0]=="W" and len(ope)<=3 and 0<=int(ope[1:])<=99:
y+=int(ope[1:])
elif ope[0]=="S" and len(ope)<=3 and 0<=int(ope[1:])<=99:
y-=int(ope[1:])
except:
continue
print(str(x)+','+str(y))

查看3道真题和解析