华为机试HJ74-又忙了好几天没刷题了

参数解析

http://www.nowcoder.com/questionTerminal/668603dc307e4ef4bb07bcd0615ea677

测试用例m='xcopy /s "C:\program files" "d:"'
其他都在代码里了

while True:
    try:
        m=input().split()
        result=[]
        count=0
        i=0
        while i in range(0,len(m)):
            if m[i].count('"')==2:
                result.append(m[i].replace('"',''))
                count+=1
                i+=1
            elif m[i].count('"')==1:
                j=0
                temp=m[i].replace('"','')
                for j in range(i+1,len(m)):
                    if m[j].count('"')==1:
                        count+=1
                        temp=temp+m[j].replace('"','')
                        break
                    else:
                        temp=temp+m[j].replace('"','')
                result.append(temp.replace('"',''))
                count+=1
                i=j+1
            else:
                result.append(m[i].replace('"',''))
                count+=1
                i+=1
        print(count)
        for i in result:
            print(i)
    except:
        break
全部评论

相关推荐

点赞 评论 收藏
分享
1 2 评论
分享
牛客网
牛客企业服务