各位大神,下面的程序有什么问题啊?
void Date::CalDay_date() //定义成员函数,计算该天是当年的第几天{
int nLDays={31,29,31,30,31,30,31,31,30,31,30,31};
int nCDays={31,28,31,30,31,30,31,31,30,31,30,31};
int res=0;
if((year%100!=0&&year%4==0)||year%400==0)
{
for(int i=0;i!=month-1;++i)
{
res+=nLDays[i];
}
res+=day;
}
else
{
for(int i=0;i!=month-1;++i)
{
res+=nCDays[i];
}
res+=day;
}
cout<<"一天是这一年的第x天"<<endl;
cout<<"x"<<"="<<res<<endl;
}