题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import sys
m=list(input().split(';'))
p,q=0,0
for i in m:
if len(i)>=2:
if str(i[0]) in 'WASD':
if str(i[1]) in '0123456789' :
if len(i)==2:
if str(i[0])=='A':
p-= int(i[1:])
if str(i[0])=='D':
p+= int(i[1:])
if str(i[0])=='W':
q+=int(i[1:])
if str(i[0])=='S':
q-=int(i[1:])
else:
if str(i[2]) in '0123456789' or i[2]==None:
if str(i[0])=='A':
p-= int(i[1:])
if str(i[0])=='D':
p+= int(i[1:])
if str(i[0])=='W':
q+=int(i[1:])
if str(i[0])=='S':
q-=int(i[1:])
l=str(p)+','+str(q)
print(l)

科大讯飞公司氛围 425人发布