萌新求助,和样例输出一样,爆零了QWQ

P5730 【深基5.例10】显示屏

Diamiko @ 2020-03-10 18:46:13

n=int(input())
s=input()
for j in range(1,6):
    cnt=1
    for i in s:
        if j==1:
            if i=='0':
                print('XXX',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('XXX',end='')
            elif i=='3':
                print('XXX',end='')
            elif i=='4':
                print('X.X',end='')
            elif i=='5':
                print('XXX',end='')
            elif i=='6':
                print('XXX',end='')
            elif i=='7':
                print('XXX',end='')
            elif i=='8':
                print('XXX',end='')
            elif i=='9':
                print('XXX',end='')
        if j==2:
            if i=='0':
                print('X.X',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('..X',end='')
            elif i=='3':
                print('..X',end='')
            elif i=='4':
                print('X.X',end='')
            elif i=='5':
                print('X..',end='')
            elif i=='6':
                print('X..',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('X.X',end='')
            elif i=='9':
                print('X.X',end='')
        if j==3:
            if i=='0':
                print('X.X',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('XXX',end='')
            elif i=='3':
                print('XXX',end='')
            elif i=='4':
                print('XXX',end='')
            elif i=='5':
                print('XXX',end='')
            elif i=='6':
                print('XXX',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('XXX',end='')
            elif i=='9':
                print('XXX',end='')
        if j==4:
            if i=='0':
                print('X.X',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('X..',end='')
            elif i=='3':
                print('..X',end='')
            elif i=='4':
                print('..X',end='')
            elif i=='5':
                print('..X',end='')
            elif i=='6':
                print('X.X',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('X.X',end='')
            elif i=='9':
                print('..X',end='')
        if j==5:
            if i=='0':
                print('XXX',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('XXX',end='')
            elif i=='3':
                print('XXX',end='')
            elif i=='4':
                print('..X',end='')
            elif i=='5':
                print('XXX',end='')
            elif i=='6':
                print('XXX',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('XXX',end='')
            elif i=='9':
                print('XXX',end='')
        if cnt!=n:
            print('.',end='')
        cnt+=1
    print('')

帮帮孩子吧


by Ryo_Yamada @ 2020-03-10 19:12:08

@弑魂丶琉璃花P 同时您i循环结束后cnt=1漏了,我用小号帮您你调了一下

n=int(input())
s=input()
cnt=1
for j in range(1,6):
    for i in s:
        if j==1:
            if i=='0':
                print('XXX',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('XXX',end='')
            elif i=='3':
                print('XXX',end='')
            elif i=='4':
                print('X.X',end='')
            elif i=='5':
                print('XXX',end='')
            elif i=='6':
                print('XXX',end='')
            elif i=='7':
                print('XXX',end='')
            elif i=='8':
                print('XXX',end='')
            elif i=='9':
                print('XXX',end='')
        if j==2:
            if i=='0':
                print('X.X',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('..X',end='')
            elif i=='3':
                print('..X',end='')
            elif i=='4':
                print('X.X',end='')
            elif i=='5':
                print('X..',end='')
            elif i=='6':
                print('X..',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('X.X',end='')
            elif i=='9':
                print('X.X',end='')
        if j==3:
            if i=='0':
                print('X.X',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('XXX',end='')
            elif i=='3':
                print('XXX',end='')
            elif i=='4':
                print('XXX',end='')
            elif i=='5':
                print('XXX',end='')
            elif i=='6':
                print('XXX',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('XXX',end='')
            elif i=='9':
                print('XXX',end='')
        if j==4:
            if i=='0':
                print('X.X',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('X..',end='')
            elif i=='3':
                print('..X',end='')
            elif i=='4':
                print('..X',end='')
            elif i=='5':
                print('..X',end='')
            elif i=='6':
                print('X.X',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('X.X',end='')
            elif i=='9':
                print('..X',end='')
        if j==5:
            if i=='0':
                print('XXX',end='')
            elif i=='1':
                print('..X',end='')
            elif i=='2':
                print('XXX',end='')
            elif i=='3':
                print('XXX',end='')
            elif i=='4':
                print('..X',end='')
            elif i=='5':
                print('XXX',end='')
            elif i=='6':
                print('XXX',end='')
            elif i=='7':
                print('..X',end='')
            elif i=='8':
                print('XXX',end='')
            elif i=='9':
                print('XXX',end='')
        if cnt!=n:
            print('.',end='')
            cnt+=1
    print('')
    cnt=1

by 空与白之影 @ 2020-03-10 19:13:02

@弑魂丶琉璃花P lz呢


by Celtic @ 2020-03-10 19:16:05

突然想起某bzoj神贴


by Diamiko @ 2020-03-10 19:16:37

@breeze末影 在每次i循环结束后cnt=1,和在每次i循环结束前cnt=1不一样吗


by Ryo_Yamada @ 2020-03-10 19:18:06

@弑魂丶琉璃花P 是啊,这就很玄学了


by Diamiko @ 2020-03-10 19:18:23

@breeze末影 我的输出确实没有多余的‘.’


by Diamiko @ 2020-03-10 19:19:47

@breeze末影 两份代码输出之后对比确实是一样的(雾


by Ryo_Yamada @ 2020-03-10 19:20:21

@弑魂丶琉璃花P 有的,如果本地输出不一样的话建议去IDE测

您每个评测记录都是Too long on line 1,我测的也确实输出了多余的.


上一页 |