题解 | #获得月份天数#
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h> int main() { int year, month = 0; int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (scanf("%d %d", &year, &month) != EOF) { int day = days[month - 1]; if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0)) { if (month == 2) day++; } printf("%d\n", day); } return 0; }
c语言刷题 文章被收录于专栏
c语言刷题题目