题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
##牛客网的python 3不支持match语句,这个程序还需要进一步修改
def zuobiao(*loo):
curpoint = [0,0]
for ll in loo:
match ll[0]:
case 'A':
curpoint[0] -= int(ll[1:])
case 'D':
curpoint[0] += int(ll[1:])
case 'S':
curpoint[1] -= int(ll[1:])
case 'W':
curpoint[1] += int(ll[1:])
return curpoint
while True:
try:
s = list(input().split(';'))
news = []
#ZIMU = 'A' or 'D' or 'S' or 'W'
#c[0] == 'A' or c[0] == 'D' or c[0] == 'S' or c[0] == 'W'
for c in s:
if len(c) == 3 and (c[0] == 'A' or c[0] == 'D' or c[0] == 'S' or c[0] == 'W') and c[1].isdigit() and c[2].isdigit():
news.append(c)
#print(news)
#print(s)
#s = ['A10','S20','W10','D30','A10']
#for s
res = zuobiao(*news)
#print(str(res))
#print(len(res))
print(','.join(map(str,res)))
except:
break