计算某年的某个月有多少天
计算某年的某个月有多少天
程序代码如下:
/* 2017年3月12日19:13:29 功能:计算某年的某个月有多少天 */ #include"stdio.h" void fun(int ,int ); int main() { int year,month; printf("please input a year and a month,use space to divide that :"); scanf("%d %d",&year,&month); fun(year,month); } void fun(int year,int mouth) { if(mouth == 1 ||mouth == 3 ||mouth == 5 ||mouth == 7 ||mouth == 8 ||mouth == 10 ||mouth == 12) { printf("%d年第%d个月有31天",year,mouth); } else if(mouth != 2) { printf("%d年第%d个月有30天",year,mouth); } else if(year % 4 == 0 || year % 400 == 0) { printf("%d年是闰年第2个月有29天",year,mouth); } else printf("%d年不是闰年第2个月有28天",year,mouth); } /* 总结: 在VC++6.0中显示的结果: —————————————————————————————————— please input a year and a month,use space to divide that :2016 2 2016年是闰年第2个月有29天 —————————————————————————————————— */