Lua脚本 题目:输入某年某月某日,判断这一天是这一年的第几天? 怎么写

2024-11-27 04:25:55
推荐回答(1个)
回答1:

function getDays(year,month,day)

local leapYear={31,29,31,30,31,30,31,31,30,31,30,31}

local commonYear={31,28,31,30,31,30,31,31,30,31,30,31}

local templateYear

local count

if year %4 ==0 then

templateYear=leapYear

else

templateYear=commonYear

end

for i=1,month-1 do

count =count +templateYear[i]

end

count =count+day

return count

end