题解 | #获得月份天数#
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h> int main() { int year,month; int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; //0为了使下标代表月份 while(scanf("%d %d",&year,&month)!=EOF) { int day = days[month]; if(month==2) { if(year%4==0 && year%100!=0 || year%400==0) { day++;//闰年二月多一天 } } printf("%d\n",day); } return 0; }