某年某月的天数

问题描述
输入年和月,判断该月有几天?
输入
输入年和月,格式为年\月.
输出量
输出该月的天数.
样本输入
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||month3||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;

}

猜你喜欢

转载自blog.csdn.net/qq_43609148/article/details/83752043