题解 | #输入整型数组和排序标识,对其元素按照升序或降序进行排序#

坐标移动

http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29


x,y=0,0
str0=input()[:-1]
list1=str0.split(";")

for i in list1:
    try:
        n=int(i[1:])
        if i[0]=="A": x=x-n
        elif i[0]=="D": x=x+n
        elif i[0]=="S": y=y-n
        elif i[0]=="W": y=y+n
        else: pass
    except:
        pass
x=str(x)
y=str(y)
print(x+","+y)


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务