题解 | #坐标移动#

坐标移动

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

全部评论

相关推荐

哈哈哈,你是老六:百度去年裁员分评不好,赶紧弄点红包
点赞 评论 收藏
分享
在笔试的大西瓜很矫健:校招数分不用想了,这经历和学历都不够用,大厂更别想,初筛都过不了,说点不好听的小厂数分都进不去(小厂也是假数分),要两个对口实习+3个项目(或者3+2),而且要有含金量才能补一点你的学历劣势。 建议刷实习,社招找数分,校招看运气,能入行业就行,可以运营转数分
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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