用c语言switch语句编写程序,输入某年某月,求该月的天数

2024-11-15 11:29:42
推荐回答(1个)
回答1:

判断一个日期是这一年中那一天。编译环境vc++6.0#include
using namespace std;
void main()
{
int i;
int sum=0;
int year,month,day;
int rick[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int conmon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
cout<<"请输入一个日期,格式:2010 10 10"<cin>>year>>month>>day;
if((year%4==0&&year%100!=0)||(year%400==0))
{
for(i=0;isum=sum+rick[i];
}
else
{
for(i=0;isum=sum+conmon[i];
}
sum=sum+day;
cout<