题解 | #坐标移动#

坐标移动

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

全部评论

相关推荐

点赞 评论 收藏
分享
见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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