题解 | #空心正方形图案#

空心正方形图案

http://www.nowcoder.com/practice/72347ee949dc47399186ee183632f303

BC111 空心正方形图案

思路:

step1:i == 1 or i == n or j == n or j == 1时打印⭐ ;

代码如下:

while True:
    try:
        n = int(input())
        i = 1
        while i <= n:
            j = n
            while j >= 1:
                if i == 1 or i == n:
                    print('* ',end='')
                elif j == n or j == 1:
                    print('* ',end='')
                else:
                    print('  ',end='')
                j -= 1
            print()
            i += 1
    except:
        break
全部评论

相关推荐

用微笑面对困难:你出于礼貌叫了人一声大姐,大姐很欣慰,她真把你当老弟
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务