请教各位高手,我这个程序在哪里出错了?
#include <iostream.h>struct Daty{
int y;
int m;
int d;
};
bool isLeap(int y)
{
return y%4==0&&y%100!=0||y%400==0;
}
int daysofMonth(int y,int m)
{
int days[12]={31,0,31,30,31,30,31,31,30,31,30,31};
if(m!=2)
return days[m-1];
else
return 28+isLeap(y);
}
int daysofDate(Daty d)
{
int days=0;
for(int y=1;y<d.y;y++)
days+=365+isLeap(y);
for(int m=1;m<d.m;m++)
days+=daysofMonth(d.y,m);
days+=d.d;
return days;
}
void main()
{
Daty d1,d2;
cout<<"input 2 datys(yyyy mm dd):";
cin>>d1.y>>d1.m>>d1.d;
cin>>d2.y>>d2.m>>d2.d;
int days1=daysofMonth(d1);
int days2=daysofMonth(d2);
cout<<"日期相差幾天:"<<days1-days2<<endl;
cout<<"星期:"<<days1%7<<''<<days2%7<<''<<endl;
}