[Python]洛谷编译错误,但ide没问题

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

foxr001 @ 2023-09-19 19:43:04

def print_num(num, line):
    match line:
        case 1:
            if num not in (1, 4):
                print("XXX", end="")
            elif num == 1:
                print("..X", end="")
            else:
                print("X.X", end="")
        case 2:
            if num in (0, 4, 8, 9):
                print("X.X", end="")
            elif num in (1, 2, 3, 7):
                print("..X", end="")
            else:
                print("X..", end="")
        case 3:
            if num == 0:
                print("X.X", end="")
            elif num in (1, 7):
                print("..X", end="")
            else:
                print("XXX", end="")
        case 4:
            if num in (0, 6, 8):
                print("X.X", end="")
            elif num == 2:
                print("X..", end="")
            else:
                print("..X", end="")
        case 5:
            if num in (1, 4, 7):
                print("..X", end="")
            else:
                print("XXX", end="")

a = int(input().strip())
b = input().strip()
for i in range(1, 6):
    for j in b:
        print_num(int(j), i)
        if j != b[-1]:
            print(".", end="")
    print()

by Terrible @ 2023-09-19 19:48:33

@foxr001

洛谷评测机语言环境信息

其中 Python 3:3.9.6, NumPy 1.21.2

是不支持 Python 3.10 才加入的 match-case 语句的。你可以留着以后洛谷升级 Python 解释器后交。


by foxr001 @ 2023-09-19 19:57:45

@Terrible 好的


|