满意答案
bbfatcat
2014.06.28
采纳率:50% 等级:7
已帮助:59人
fun(int a)
{
if((a%4==0&&a%100!=0)||a%400==0) return (1);
else return (0);
}/*用来判断是否为闰年*/
fun1(int year,int month,int day)
{ int c[12],i,j,k=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};
j=fun(year);
if(j==1) for(i=0;i<12;i++) c[i]=a[i];
if(j==0) for(i=0;i<12;i++) c[i]=b[i];
for(i=0;i
k=k+day;
return k;
}/*用来求你说的day1,day2*/
main()
{
int month=0,year=0,day=0,bmonth=0,byear=0,bday=0,sum=0,i;
while(byear<1||byear>32000)
{ printf("please input the birthyear:\n");
scanf("%d",&byear); }
while(bmonth<1||bmonth>12)
{ printf("please input the birthmonth:\n");
scanf("%d",&bmonth); }
while(bday<1||bday>31)
{ printf("please input the birthday:\n");
scanf("%d",&bday);}
printf("your birthday is:%d %d %d\n",byear,bmonth,bday);
while(year<1||year>32000)
{ printf("please input the coutyear:\n");
scanf("%d",&year); }
while(month<1||month>12)
{ printf("please input the coutmonth:\n");
scanf("%d",&month); }
while(day<1||day>31)
{ printf("please input the coutday:\n");
scanf("%d",&day);}
printf("cout day is:%d %d %d\n",year,month,day);
printf("day1=%d\nday2=%d\n",fun1(byear,bmonth,bday),fun1(year,month,day));
for(i=byear;i
sum+=365+(fun(i));
printf("anser:%d",fun1(year,month,day)-fun1(byear,bmonth,bday)+sum);
getch();
}
00分享举报