lua官方例程--温度换算(摄氏、华氏)
程序员文章站
2022-03-18 18:08:56
...
摄氏温度c ,将其转化为华氏温度f ,转换公式为:f=c*9/5+32
--从-20到50-1,步长为10,即执行一次后c0+=10
for c0=-20,50-1,10 do
io.write("C ")
for c=c0,c0+10-1 do
io.write(string.format("%3.0f ",c))
end
io.write("\n")
io.write("F ")
for c=c0,c0+10-1 do
f=(9/5)*c+32
io.write(string.format("%3.0f ",f))
end
io.write("\n\n")
end
推荐阅读