for 循环正打印正九九乘法表
for i in range(1, 9 + 1):
for j in range(1, i + 1):
print("{}X{}={}".format(j, i, i * j), end="\t")
print("")
print("="*50)

while 循环打印正九九乘法表
i = 1
while i <= 9:
j = 1
while j <= i:
print("{}X{}={}".format(j, i, i * j), end="\t")
j += 1
i += 1
print("")
print("="*80)

for循环倒着打印的九九乘法表
for i in range(9, 1 - 1, -1):
for k in range(1, 9 - i + 1):
print(end="\t\t")
for j in range(i, 0, -1):
print("{}X{}={}".format(j, i, i * j), end="\t")
print("")
print("="*80)

while循环倒着打印九九乘法表
i = 9
while i >= 1:
j = i
k = 1
while k <= 9 - i:
print(end="\t\t")
k += 1
while j > 0:
print("{}X{}={}".format(j, i, i * j), end="\t")
j -= 1
i -= 1
print("")
print("="*80)

网友评论