题解 | #获得月份天数#
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h> //他喵的,括号太多,搞昏头了 int main() { int year, month; while(scanf("%d %d", &year, &month)!=EOF) { int arr1[7]={1,3,5,7,8,10,12}; int arr2[4]={4,6,9,11}; if((year%4==0&&year%100!=0)||year%400==0) { for(int i=0;i<7;i++) { if(month==arr1[i]) { printf("31\n"); break; } else if(month==arr2[i]) { printf("30\n"); break; } } if(month==2) { printf("29\n"); } } else { for(int i=0;i<7;i++) { if(month==arr1[i]) { printf("31\n"); break; } else if(month==arr2[i]) { printf("30\n"); break; } } if(month==2) { printf("28\n"); } } } return 0; }