题解 | #坐标移动#

坐标移动

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))

全部评论

相关推荐

03-10 16:35
门头沟学院 Java
hxyz61:问他要个微信,这里不方便骂人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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