zgjja


私信TA

用户名:zgjja

访问量:10822

签 名:

X_X

等  级
排  名 147
经  验 7113
参赛次数 0
文章发表 71
年  龄 0
在职情况 学生
学  校
专  业 X_X

  自我简介:

解题思路:
利用标准库中的无限迭代器产生数字,然后根据计算的长度控制循环的结束

注意事项:

参考代码:

from itertools import count

n, last_index = int(input()), 0
temp, cycle = '', count(1)
while len(temp) < 4 * n - 4:
    temp += str(next(cycle))
temp = temp[:4 * n - 4]
print(((2 * (n - 2) + 2) // 2) * "." + temp[0])
for i in range(1, n - 1):
    print(((2 * (n - 2) + 2) // 2 - i) * "." + temp[i] + \
          (2 * (i - 1) + 1) * "." + temp[-i])
    last_index = i
print(temp[last_index + 1:-last_index:1])


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区