99乘法表中文版

源代码

a = ["" ,"", "", "", "", "", "", "", "", ""]
for i in range(1, 10):
    for j in range(1, i+1):
        print(a[j], end="")
        print(a[i], end="")
        if i * j < 10:
            print("", end="")
            print(a[i*j], end="  ")
        else:
            t1 = i * j // 10
            t2 = i * j % 10
            if t1 == 1 and t2 == 0:
                print("一十", end="  ")
            else:
                if t1 > 1:
                    print(a[t1], end="")
                print("", end="")
                print(a[t2], end="")
                if t1 == 1:
                    print("  ", end="")
                if t2 == 0:
                    print("  ", end="")
        if i == j:
            print("")
        else:
            print("", end="\t")

运行结果

猜你喜欢

转载自www.cnblogs.com/Chaosliang/p/11595030.html