【发布时间】:2018-03-01 04:05:51
【问题描述】:
我的 lua 代码做错了什么?
local which
print("Type f to convert fahrenheit to celsius and c to convert celsius to fahrenheit")
which = io.read()
repeat
if which=="f" then
local c
local f
print("input your fahrenheit temperature")
f = tonumber(io.read())
c = (f-32)/1.8
print(c)
end
elseif which=="c" then
local ce
local fa
print("input your celsius temperature")
c = tonumber(io.read())
f = (c*1.8)+32
end
else do
print("Type f to convert fahrenhiet to celsius and c to convert celsius to fahrenheit")
until which=="f" or which=="c"
【问题讨论】:
-
保持一致的缩进让事情更清晰:缩进你的重复主体......这将帮助你解决很多此类错误(尽管不完全是这种情况)。
标签: lua