swift计算 switch case
var year = 2016 var month = 7 var day = 6; let daysOfFeb = year % 4 == 0 && year%100 != 0 || year % 400 == 0 ?29:28 var count = 0 // 定义一个变量 代表结果 switch month{ case 12:count += 30; fallthrough case 11:count += 31; fallthrough case 10:count += 30; fallthrough case 9:count += 31; fallthrough case 8:count += 31; fallthrough case 7:count += 30; fallthrough case 6:count += 31; fallthrough case 5:count += 30; fallthrough case 4:count += 31; fallthrough case 3:count += daysOfFeb; fallthrough case 2:count += 31; fallthrough case 1:count += day default:break } print("\(year)年\(month)月\(day)日 是一年当中的第\(count)天")
用心做人,用脑做事!----鹏鹏张