题解 | #获得月份天数#
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h> int Leap(int year); int main() { int mon = 0; int year = 0; while ( 2== scanf("%d %d", &year, &mon)) { if (4 == mon || 6 == mon || 9 == mon || 11 == mon) { printf("30"); } else if (2 == mon) { if (Leap(year)) { printf("29"); } else { printf("28"); } } else { printf("31"); } printf("\n"); } return 0; } int Leap(int year) { return ((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0)); }