华为2020届暑期实习笔试第二题20190403

题目描述:对输入字符串检查是否存在非法字符,输出合法字符串(去重)和非法字符串(不去重),对合法字符串循环左移10次,再进行排序输出

在这里插入代码片
temp2 = []
temp3 = []
temp4 = []
temp7=[]
for t in range(100):
    x = input()
    temp = []
    temp5=[]
    flag = 0
    for i in x:
        if (i >= '0' and i <= '9' or i >= 'a' and i <= 'z' or i>='A' and i<='Z'):
            flag=1
    if flag == 1:
        for i in x:
            if i not in temp:
                temp.append(i)
                temp5.append(i)
        temp4.append(temp5)
        for i in range(10):
            x = temp[0]
            temp.pop(0)
            temp.append(x)
    temp2.append(temp)
    temp7.append(temp)
    if flag == 0:
        temp3.append(x)
    if x == '':
        for x5 in temp4:
            for h in x5:
                print(h, end='')
            print(' ',end='')
        print('\n')

        for x3 in temp3:
            print(x3, end='')
            print(' ',end='')
        print('\n')
        for x2 in temp2:
            for j in x2:
                print(j, end='')
            print(' ',end='')
        print('\n')
        i = sorted(temp7)
        i.pop(0)
        for x6 in i:
            for h in range(len(x6)):
                 print(x6[h], end='')
            print(' ',end='')
        break

你可能感兴趣的:(华为2020届暑期实习笔试第二题20190403)