C语言实验——某年某月的天数
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
输入年和月,判断该月有几天?
Input
输入年和月,格式为年\月。
Output
输出该月的天数。
Example Input
2009\1
Example Output
31
Hint
注意判断闰年啊
Author
#include <stdio.h>
int main()
{
int year,month;
scanf("%d\\%d",&year,&month);
if(month==1)
printf("31\n");
else if(month==3)
printf("31\n");
else if(month==4)
printf("30\n");
else if(month==5)
printf("31\n");
else if(month==6)
printf("30\n");
else if(month==7)
printf("31\n");
else if(month==8)
printf("31\n");
else if(month==9)
printf("30\n");
else if(month==10)
printf("31\n");
else if(month==11)
printf("30\n");
else if(month==12)
printf("31\n");
else if(month==2)
{
if((year%4==0&&year%100!=0)||(year%400==0))
printf("29\n");
else
printf("28\n");
}
return 0;
}