在python中填充权为1/4的矩形框图案X

时间:2019-10-30 13:28:42

标签: python

我编写了一个程序来在python中打印矩形框图案。但是我需要编辑以'#'填充框右1/4的位置

这只是在python中打印矩形框图案

def pattern(n):
for i in range(0, n):
    for j in range(0, n):
        if (i == 0 or i == n - 1
                or j == 0 or j == n - 1
                or i == j or i == n - 1 - j):
            print("#", end="")

        else:
            print(" ", end="")
    print("")

 input:7
 #  output
 #######
 ##   ##
 # # # #
 #  #  #
 # # # #
 ##   ##
 #######


but I need
#######
##   ##
# # ###
#  ####
# # ###
##   ##
#######

1 个答案:

答案 0 :(得分:2)

    <form class="form-signin" action='<spring:url value="/j_spring_security_check" />' method="POST">
        <h3 class="form-signin-heading">Please sign in</h3>

        <input type="text" class="input-block-level loginTextInput" placeholder="Username" name="j_username" id="j_username" autofocus="autofocus" >
        <input type="password" class="input-block-level loginTextInput" placeholder="Password" name="j_password" id="j_password">
        <button class="onWhite" type="submit">Sign in</button>

        <div>&nbsp;</div>

        <c:if test="${param.login_error == '1'}">
            <div class="alert alert-error">
                    <strong>Error:</strong> Invalid username/password combination.          
            </div>
        </c:if>
        <c:if test="${param.logout == '2'}">
            <div class="alert">
                You have been logged out.
            </div>
        </c:if>

退出:

def pattern(n):
    for i in range(0, n):
        for j in range(0, n):
            if (i == 0 or i == n - 1
                    or j == 0 or j == n - 1
                    or i == j or i == n - 1 - j
                    or (i < j and i > n -1 -j)):
                print("#", end="")

            else:
                print(" ", end="")
        print("")


print (pattern(15))