#include <iostream.h> void main() { int year,month,day; cout<<"输入该年月"<<endl; cin>>year; cin>>m
帮我查查哪错的,题目是:编写程序由键盘输入年、月,输出该年该月的天数。高手啊,帮帮忙吧~~~~#include<iostream.h>voidmain(){intyear...
帮我查查哪错的,
题目是:编写程序由键盘输入年、月,输出该年该月的天数。
高手啊,帮帮忙吧~~~~
#include <iostream.h>
void main()
{
int year,month,day;
cout<<"输入该年月"<<endl;
cin>>year;
cin>>month;
cin>>day;
switch(month)
{
case 1:
int d=31;
break;
case 2:
if( year%400==0||( year%4==0&& year%100!=0))
int day=29;
else
int day=28;
break;
case 3:
int day=31;
break;
case 4:
int day=30;
break;
case 5:
int day=31;
break;
case 6:
int day=30;
break;
case 7:
int day=31;
break;
case 8:
int day=31;
break;
case 9:
int day=30;
break;
case 10:
int day=31;
break;
case 11:
int day=30;
break;
case 12:
int day=31;
break;
}
cout<<"该年该月的天数为"<<day<<endl;
} 展开
题目是:编写程序由键盘输入年、月,输出该年该月的天数。
高手啊,帮帮忙吧~~~~
#include <iostream.h>
void main()
{
int year,month,day;
cout<<"输入该年月"<<endl;
cin>>year;
cin>>month;
cin>>day;
switch(month)
{
case 1:
int d=31;
break;
case 2:
if( year%400==0||( year%4==0&& year%100!=0))
int day=29;
else
int day=28;
break;
case 3:
int day=31;
break;
case 4:
int day=30;
break;
case 5:
int day=31;
break;
case 6:
int day=30;
break;
case 7:
int day=31;
break;
case 8:
int day=31;
break;
case 9:
int day=30;
break;
case 10:
int day=31;
break;
case 11:
int day=30;
break;
case 12:
int day=31;
break;
}
cout<<"该年该月的天数为"<<day<<endl;
} 展开
2个回答
展开全部
//物轮让错误主要有两个,day不需要输入,day前面有多余的int。罩局下面是正确的程序:
#include <iostream.h>
void main()
{
int year,month,day;
cout<<"输入该年月"<<endl;
cin>>year;
cin>>month;
//cin>>day;天是计算得出,不需要输入
switch(month)
{
case 1:
day=31;
break;
case 2:
if( year%400==0||( year%4==0&& year%100!=0))
day=29;
else
day=28;
break;
case 3:
day=31;
break;
case 4:
day=30;
break;
case 5:
day=31;
break;
case 6:
day=30;
break;
case 7:
day=31;
break;
case 8:
day=31;
break;
case 9:
day=30;
break;
case 10:
day=31;
break;
case 11:
day=30;
break;
case 12:
day=31;
break;
}
cout<<"该桐岁年该月的天数为"<<day<<endl;
}
#include <iostream.h>
void main()
{
int year,month,day;
cout<<"输入该年月"<<endl;
cin>>year;
cin>>month;
//cin>>day;天是计算得出,不需要输入
switch(month)
{
case 1:
day=31;
break;
case 2:
if( year%400==0||( year%4==0&& year%100!=0))
day=29;
else
day=28;
break;
case 3:
day=31;
break;
case 4:
day=30;
break;
case 5:
day=31;
break;
case 6:
day=30;
break;
case 7:
day=31;
break;
case 8:
day=31;
break;
case 9:
day=30;
break;
case 10:
day=31;
break;
case 11:
day=30;
break;
case 12:
day=31;
break;
}
cout<<"该桐岁年该月的天数为"<<day<<endl;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询