使用for循环
n = 9 i = 1 for i in range(1,n+1,1): for j in range(1, i+1, 1): print("%d*%d=%d"%(i,j,i*j),end=' ') print(' ')
使用while循环
i = 1 n = 9 while i<10: j = 1 while j<=i: print("%d*%d=%d"%(i,j,i*j),end=' ') j += 1 print(" ") i += 1
使用for循环
n = 9 i = 1 for i in range(1,n+1,1): for j in range(1, i+1, 1): print("%d*%d=%d"%(i,j,i*j),end=' ') print(' ')
使用while循环
i = 1 n = 9 while i<10: j = 1 while j<=i: print("%d*%d=%d"%(i,j,i*j),end=' ') j += 1 print(" ") i += 1