#include<stdio.h> int main(){ int y = 0; int m = 0;//天数固定设计一个数组 int arr[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; while (scanf("%d %d", &y, &m) != EOF){ int day = arr[m];//不要对arr[m]直接修改会改动数组内容 if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0){ if (m == 2) day += 1; } printf("%d\n", day); } return 0; }