首先,我们来回忆一下99乘法表长什么样子吧
进入正题:实现99乘法表
一、For循环
1 for i in range(1,10): 2 for j in range(1,i+1): 3 print("%d*%d=%d"%(i,j,i*j),end=" ") 4 print("")
二、While循环
1 n=1;sum=1 2 while n <= 9: 3 i = 1 4 while i <= n: 5 sum = i*n 6 print('%d*%d=%d'%(i,n,sum),end=' ') 7 i = i+1 8 print('') 9 n = n+1