1. 程式人生 > >某年某月的天數

某年某月的天數

問題描述
輸入年和月,判斷該月有幾天?
輸入
輸入年和月,格式為年\月.
輸出量
輸出該月的天數.
樣本輸入
2009\1
樣本輸出
31

注意char c。有一個\要輸入

#include <stdio.h>
int main()
{
int year,month;
int isLeap=0;
int days;
char c;
scanf("%d",&year);
scanf("%c",&c);
scanf("%d",&month);
if((year%40&&year%100!=0)||(year%4000))
isLeap=1;
if(month1||month

3||month5||month7||month8||month10||month12)
days=31;
if(month
4||month6||month9||month11)
days=30;
if(isLeap
1&&month2)
days=29;
if(isLeap
0&&month==2)
days=28;
printf("%d",days);
return 0;

}