#include<stdio.h> int main() { int year = 0;//输入的年分 int month = 0;//输入的月份 int x = 0;//该月天数 while(scanf("%d %d",&year,&month )!= EOF) { switch(month){ case 1 : x = 31; break; case 2 : x = 28; break; case 3: x = 31; break; case 4: x = 30; break; case 5: x = 31; break; case 6: x = 30; break; case 7: x = 31; break; case 8: x = 31; break; case 9: x = 30; break; case 10: x = 31; break; case 11: x = 30; break; case 12: x = 31; break; } if((year%4==0 && year%100!=0)||year%400==0)//判断该年份是不是闰年。若是,则二月为29天,若不是,则二月为28天 if(month == 2) x = 29; printf("%d\n",x); }; return 0; }