lua腳本筆記-(1)-控制語句if

-- 1. if end
a=1
if a==1 then 
  print(a)
end

-- 2. if else end
b=1
if b < 10 then
  print('b<10 and b='..b)
else
  print('b>10 and b='..b)
end

-- 3. if elseif else end
score=64
if score>=0 and score<60 then
  print('不及格, score='..score)
elseif score>=60 and score<80 then
  print('成績中等, score='..score)
elseif score>=80 and score<=100 then
  print('成績優良, score='..score)
else 
  print('錯誤的分數!, score='..score)
end
相關文章
相關標籤/搜索