zoukankan      html  css  js  c++  java
  • if与while相互嵌套,菱形*的实现.py

    """
        *        
       * *       
      * * *      
     * * * *     
    * * * * *    
     * * * *     
      * * *      
       * *       
        *        
    """

    # -*-coding:utf-8-*-

    # i = 0
    #
    # while i < 9:
    #
    #     if i < 5:
    #
    #         print(" "*(4-i),"* "*(i+1))
    #
    #     else:
    #
    #         print(" "*(i-4),"* "*(9-i))
    #
    #     i += 1


    """
        *        1 4 1
       * *       2 3 2
      * * *      3 2 3
     * * * *     4 1 4
    * * * * *    5 0 5
     * * * *     6 1 4
      * * *      7 2 3
       * *       8 3 2
        *        9 4 1
    """

    row = 1

    while row <= 9:

        if row <= 5:

            print(" "*(5-row),end="")

            col = 1

            while col <= row:


                print("* ",end="")

                col += 1

            print("")

        else:

            print(" "*(row-5),end="")

            col = 1

            while col <= (10 -row):

                print("* ",end="")


                col += 1
            print("")

        row += 1

  • 相关阅读:
    修改程序堆栈的可执行属性
    【转】关于C语言生成不重复的随机数
    Apriori算法
    远程连接服务器端Jupyter Notebook
    Android KeyLogger Demo
    Windows消息钩取
    基址重定位表&.reloc节区
    调试UPX压缩的notepad
    PE文件格式
    apk逆向
  • 原文地址:https://www.cnblogs.com/hm-hx-ldy/p/8260906.html
Copyright © 2011-2022 走看看