zoukankan      html  css  js  c++  java
  • python04 while循环

     #下图为到三角:
    num=5 while num>0: tem=num while tem>0: #嵌套循环 print("#",end=" ") tem-=1 print() num-=1

    #a=1000
    b=a

    b=1000
    a=900

    九九乘法表:

    倒序:
    first=9 #second=9 while first>0: tem=1 while tem<=first: # print(tem,"*",first,"=",first*tem,end=" ") print(str(tem)+"*"+str(first)+"="+str(first*tem),end=" ") # 是制表符 是换行 print()默认换行 tem+=1 #print(first,"*",first,"=",first) print() first-=1 正序: first=1 #second=9 while first<=9: tem=1 while tem<=first: # print(tem,"*",first,"=",first*tem,end=" ") print(str(tem)+"*"+str(first)+"="+str(first*tem),end=" ") #第二行是数字强转字符串,通过+连接起来 tem+=1 #print(first,"*",first,"=",first) print() first+=1

    a>b  yi         #>因为旁边有两个数字,所以被称为二幕运算符或者二元运算符。

    not a>b    #not 因为右边只有一个整体,所以被称为一幕运算符或者一元运算符

    #and  not   or 运算符优先级用()来表示。

    while 条件1:

        ..........

        while 条件2:

         ..........

    break 中断某次循环

    continue 跳过当次循环

    #while 循环结构:

    while 判断条件:

      执行语句....

    else:

      执行语句...

    while循环else语句比较特殊,只有正常结束条件(非break)下才会执行。  

  • 相关阅读:
    不可重叠最长重复子串
    离散化
    hash是一门优雅的暴力
    Detect the Virus (字符串转化+AC自动机)
    病毒侵袭(AC自动机变形)
    hdu2069(Coin Change)
    Hie with the Pie(poj3311)
    poj3254(状压dp入门第一道题,很详细)
    map系统学习
    ACM-ICPC 2018 南京赛区网络预赛 B. The writing on the wall
  • 原文地址:https://www.cnblogs.com/minkillmax/p/7868730.html
Copyright © 2011-2022 走看看