程序:
#include<stdio.h>
#define N 30
#define N1 31
int main(){
int year = 0,month = 0, day = 0;
printf("请输入年月:\n");
scanf("%d %d",&year,&month);
if(month>12){
printf("NO");
}else{
if(month==2){
day = (year%4==0&&year%100!=0)||(year%400==0)? 29:28;
}else{
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: day = N1;break;
default : day = N;
}
}
printf("天数:%d",day);
}
return 0;
}
日期: 2022-1-3