回复:(yuziguang)[求助] 一个C++程序
初学者代码可以简单点`我写了个比较简单容易看的``仅供参考``
#include <iostream>
using namespace std;
bool Isleap(int y)
{
return y%4==0 && y%100!=0 || y%400==0;
}
int Dom(int y , int m )
{
int d ;
if(m==2)
{
if(Isleap(y))
d = 29;
else
d = 28;
}
else if(m%2==1 && m<=7 || m%2==0 && m>=8)
d = 31;
else
d = 30 ;
return d;
}
int coutday(int y , int m , int d)
{
int day=0,i;
for(i=1;i<m;i++)
day = day + Dom(y , i);
day = day + d;
return day;
}
int main()
{
int year , month , day;
cout<<"please input year , month , day:"<<endl;
cin>>year>>month>>day;
cout<<"the reason is"<<coutday(year,month,day)<<endl;
return 0;
}