Swift if else 練習題: 判斷閏年

Vince Lee
Vince Lee
Jul 30, 2017 · 1 min read

寫程式真的不行用抄的,有些看過去覺得自己好像懂,實際遇到問題卻發現什麼都不會。

#一定要操作過啊傻蛋李

func isLeapYear(_ year: Int) -> Bool{switch year {case let yearN where yearN % 400 == 0:return truecase let yearN where yearN % 4 == 0 && yearN % 100 != 0:return truedefault:return false}return isLeapYear(year)}

    Vince Lee

    Written by

    Vince Lee

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade