回复 2楼 love云彩
#include <stdio.h>
int js(int x,int y,int z)
{
int i;
int day0=0;
int a[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(z==0)
{
for(i=0;i<=y-1;i++)
day0=day0+a[i];
return day0+x;
}
else
{
for(i=0;i<=y-1;i++)
day0=day0+b[i];
return day0+x;
}
}
int main(void)
{
int year[2];
int mon[2];
int day[2];
int day0=0;
int day1,day2;
int i;
int z;
printf("enter your date of birth\n");
scanf("%d%d%d",&year[0],&mon[0],&day[0]);
printf("enter the date now\n");
scanf("%d%d%d",&year[1],&mon[1],&day[1]);
if(i%4==0)
{
z=0;
day1=js(day[0],mon[0],z);
day0=366-day1;
}
else
{
z=1;
day1=js(day[0],mon[0],z);
day0=365-day1;
}
for(i=year[0]+1;i<=year[1];i++)
{
if(i==year[1])
{
if(year[1]%4==0)
{
z=0;
day2=js(day[1],mon[1],z);
day0=day0+day2;
break;
}
if(year[1]%4!=0)
{
z=1;
day1=js(day[0],mon[0],z);
day2=js(day[1],mon[1],z);
day0=day0+day2;
break;
}
}
if(i%4==0)
day0=day0+366;
else
day0=day0+365;
}
printf("%d",day0);
}
有哪里不对...