为什么CE?可互
查看原帖
为什么CE?可互
1161928
wrup_AC_28楼主2023/12/6 22:37

Compile Error

py做的

# 读取输入
lines = []
while True:
    try:
        line = input()
        if line == '':
            break
        lines.append(line)
    except EOFError:
        break

# 找到最长的行
max_length = max(len(line) for line in lines)

# 计算框的宽度
width = max_length + 4

# 输出顶部边框
print('*' * width)

# 输出每一行的内容
for line in lines:
    # 计算左边和右边的空格数量
    spaces = width - 2 - len(line)
    left_spaces = spaces // 2
    right_spaces = spaces - left_spaces

    # 输出带有空格的行
    print('*' + ' ' * left_spaces + line + ' ' * right_spaces + '*')

# 输出底部边框
print('*' * width)
2023/12/6 22:37
加载中...