6 2 輸出每個月的天數

2021-10-10 17:42:26 字數 894 閱讀 8338

本題要求實現乙個簡單函式,能計算給定的年份和月份的天數。使得可以利用該函式,輸出給定年份中每個月的天數。其中1、3、5、7、8、10、12月有31天,4、6、9、11月有30天,2月平年有28天,閏年有29天。判斷閏年的條件是:能被 4 整除但不能被 100 整除,或者能被 400 整除。

函式介面定義:

int

monthdays

(int year,

int month)

;

其中year和month是使用者傳入的引數,如果1≤ month≤12,該函式必須返回year年month月的天數。

裁判測試程式樣例:

#include

intmonthdays

(int year,

int month)

;int

main()

return0;

}/* 你的**將被嵌在這裡 */

輸入樣例1:

2000
輸出樣例1:

31

2931

3031

3031

3130

3130

31

輸入樣例2:

2001
輸出樣例2:

31

2831

3031

3031

3130

3130

31

int

monthdays

(int year,

int month)

}

js計算每個月的總天數

js中相關日期的計算 var year new date getfullyear 計算當前年份 month new date getmonth 1,計算當前月份 dates new date getdate 計算當前日期 week new date getday 計算當前前是週幾 hours new...

mysql查詢每個月的資料

select create time,from unixtime create time as create date,month from unixtime create time as monthno,year from unixtime create time as myyear,title ...

統計每個月兔子的總數

有乙隻兔子,從出生後第3個月起每個月都生乙隻兔子,小兔子長到第三個月後每個月又生乙隻兔子,假如兔子都不死,問每個月的兔子總數為多少?這個問題可能我比較笨,看大多數解釋都是一句話,f n f n 1 f n 2 但是總有點想不明白這個。列了個 才看清楚咋回事。月份1 2345 67兔子總數11 235...