ALl WA,Python 为啥呀,测例能过
查看原帖
ALl WA,Python 为啥呀,测例能过
1202850
ShiShen_hu楼主2024/11/20 22:42
def print_data():
    for i in data:
        print(f"{i:>5}", end="")

    print()


def f(i):
    if i == n:
        return

    data[0], data[i] = data[i], data[0]
    data[1:] = sorted(data[1:])
    print_data()
    for x in range(1, len(data)):
        for y in range(x + 1, len(data)):
            data[x], data[y] = data[y], data[x]
            print_data()

    data.sort()
    f(i + 1)


n = int(input())
data = [i for i in range(1, n+1)]
f(0)
2024/11/20 22:42
加载中...