A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

# 九九乘法表1
j = 0
while j < 9:
    j += 1
    i = 0
    while i < j:
        i += 1
        print("%d * %d = %d" % (i,j,i*j),end="\t")
    print()

print("-"*100)

# 九九乘法表2
j = 10
while j >0:
    j -= 1
    i = 0
    while i < j:
        i += 1
        print("%d * %d = %2d" % (i,j,i*j),end=" ")
    print()

print("-"*100)

# 九九乘法表3
j = 9
while j >0:
    i = 9
    while i >= j:
        print("%d * %d = %2d" % (i,j,i*j),end=" ")
        i -= 1
    print()
    j -= 1



print("-"*100)

# 九九乘法表4
j = 0
while j < 9:
    j += 1
    print(" " * 11 * (9 - j), end="")
    i = j
    while i > 0:
        print("%d * %d = %2d" % (i,j,i*j),end=" ")
        i -= 1
    print()



print("-"*100)

# 九九乘法表5
j = 10
while j >0:
    j -= 1
    i = j
    print(" " * 11 * (9 - j), end="")
    while i > 0:
        print("%d * %d = %2d" % (i,j,i*j),end=" ")
        i -= 1
    print()

print("-"*100)

# 九九乘法表6
for i in range(1, 10):
    for j in range(1, i + 1):
        print(f"{i} * {j} = {i*j}", end="\t")
    print()

print("-"*100)

# 九九乘法表7
for i in range(9, 0, -1):
    for q in range(1, i + 1):
        print(f"{i} * {q} = {i*q}", end="\t")
    print()


print("-"*100)

# 九九乘法表8
for i in range(1, 10):
    print(" " * 11 * (9 - i), end="")
    for j in range(1, i + 1):
        print("%d * %d = %2d" % (i, j, i * j), end=" ")
    print()

print("-"*100)

# 九九乘法表9
for i in range(9,0,-1):
    print(" " * 11 * (9 - i), end="")
    for j in range(1, i + 1):
        print("%d * %d = %2d" % (i, j, i * j), end=" ")
    print()

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马