zoukankan      html  css  js  c++  java
  • 基本编程练习第二波

    1、用* 表示一个三角形

     1 ## 倒三角形
     2 line = 5
     3 
     4 while line > 0:
     5     i = line
     6     while i > 0:
     7         print('*',end="")
     8         i -= 1
     9     print()
    10     line -= 1
    11 
    12 ## 正三角形
    13 
    14 line = 1
    15 
    16 while line<=5:
    17     i = line
    18     while i>0:
    19         print('*',end="")
    20         i -= 1
    21     print()
    22     line += 1
    23 ## 正三角形
    24 
    25 line = 1
    26 
    27 while line <=5:
    28     tmp = 1
    29     while tmp <= line:
    30         print('*',end='')
    31         tmp += 1
    32     print()
    33     line += 1
    View Code

    2、用*表示一个长方形

     1 #_author:Administrator
     2 #date: 2018/1/6
     3 
     4 height = int(input('高:'))
     5 width = int(input('宽:'))
     6 
     7 # num_height = 1
     8 # while num_height <= height:
     9 #     num_width = 1
    10 #     while num_width <= 
    11 #         print("*",end="")
    12 #         num_width += 1
    13 #     print()
    14 #     num_height += 1
    15 
    16 while height > 0:
    17     num_width = width
    18     while num_width > 0:
    19         print('*',end='')
    20         num_width -= 1
    21     print()
    22     height -= 1
    View Code

    3、九九乘法表

    1 fst = 1
    2 
    3 while fst <= 9:
    4     sec = 1
    5     while sec <= fst:
    6         print( str(fst)  +'*' +str(sec) + '=' +str(sec * fst), end='	')
    7         sec += 1
    8     print()
    9     fst += 1
    View Code
    为什么要坚持,想一想当初!
  • 相关阅读:
    hust 1260 Dominos && hust 1516 Dominos
    poj 1149 PIGS
    hust 1230 beautiful
    poj 1469 COURSES
    hdu 3062 Party
    hust 1027 Enemy Target!
    hdu 3415 Max Sum of Max-K-sub-sequence
    简单的实现轮播代码
    window.parent与window.openner区别介绍
    plupload使用指南(转)
  • 原文地址:https://www.cnblogs.com/JerryZao/p/8591887.html
Copyright © 2011-2022 走看看