我在做我的lua代碼有什麼問題?重複,直到在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"
保持一致的縮進使事情更加清晰:縮進你的重複主體......這將幫助你解決很多這種類型的錯誤(儘管不完全是這個實例)。 – jpjacobs 2013-03-22 09:52:47