a= 0
while(a<9)do
local s=""
b= 0
a=a+1
while(b<9)do
b=b+1
if (b<=a) then
s=s..a.."x"..b.."="..a*b
if a~=b then
s=s.."\t"
end
end
end
print(s)
end
a=10
while(a>1)do
local s = ""
a=a-1
b=0
while(b<9)do
b=b+1
if(b<=a)then
s=s..string.format( "%dX%d=%d\t",a,b,a*b )
end
end
print(s)
end
本文通过使用Lua编程语言展示了两种不同的方法来生成九九乘法表。第一种方法采用字符串连接的方式进行输出,第二种方法则利用了string.format函数进行格式化输出,使得输出更加清晰易读。
936

被折叠的 条评论
为什么被折叠?



