| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
如何用Python打印如下的字符图案 
               * 
            *    *     
         *    *    * 
       *    *    *    * 
     *    *    *    *    * 
   *    *   *    *    *    * 
 *    *   *    *    *   *    * 
    *    *   *    *    *    * 
      *    *    *    *    * 
         *    *    *    * 
            *    *    * 
               *    *  
                  * 
            
- n = int(input())
 
 - for i in range(2 * n - 1):
 
 -     k = i + 1 if i < n else 2 * n - i - 1
 
 -     s = ' ' * (n - k) + '* ' * (k)
 
 -     print(s)
 
  复制代码
        运行实况:
 - D:\[00.Exerciese.2022]\Python>python x.py
 
 - 7
 
 -       *
 
 -      * *
 
 -     * * *
 
 -    * * * *
 
 -   * * * * *
 
 -  * * * * * *
 
 - * * * * * * *
 
 -  * * * * * *
 
 -   * * * * *
 
 -    * * * *
 
 -     * * *
 
 -      * *
 
 -       *
 
  
- D:\[00.Exerciese.2022]\Python>
 
  复制代码 
 
 
 |   
 
 
 
 |