我编的出了点问题
主要是month和day函数的函数功能的实现
#include<stdio.h>
struct date
{ int year;
int mouth;
int day;};
int year(struct date *p,struct date *q)
{int flag,sum=0;
while(p->year<=q->year)
{if((p->year%4==0)&&(p->year%100==0))
flag=1;
if(p->year%400==0)
flag=1;
else flag=0;
if(flag==1)
sum+=366;
else sum+=365;}
return(sum);
}
int day(int flag,struct date *p,struct date *q)
{int sum=0;
switch(flag)
{case 1:for(;p->day<=31;p->day++)
{sum+=1;return(sum);break;}
case 0:for(;p->day<=30;p->day++)
{sum+=1;return(sum);break;}
case -1:for(;p->day<=30;p->day++)
{sum+=1;return(sum);break;}}
}
int mouth(struct date *p,struct date *q)
{int flag,sum=0;
if(p->mouth<q->mouth)
while(p->mouth++<=q->mouth)
if((p->mouth%2==1)&&p->mouth<=7&&(p->mouth%2==0)&&p->mouth<=12)
{flag=1;sum+=day(flag,p->day,q);p->day=1;}
else if(p->mouth/2==1)
{flag=-1;sum+=day(flag,p->day,q);p->day=1;}
else {flag=0;sum+=day(flag,p->day,q);p->day=1;}
return(sum);
}
void main()
{struct date *p,*q;
int sum=0;
printf("please print:\n");
scanf("%d%d%d%d%d%d",p->year,p->mouth,p->day,q-year,q->mouth,q->day);
sum=year(p,q)+mouth(p,q);
printf("your life is running in %d day!",sum);
}
大家帮我看一下啊,多谢啦