【C】#获得月份天数#
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h> int main() { int year = 0; int month = 0; int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (scanf("%d %d", &year, &month) != EOF) { if (month == 2) { if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { printf("%d\n", day[1] + 1); } else { printf("%d\n", day[1]); } } else { printf("%d\n", day[month - 1]); } } return 0; }