lvyouzi 于 2016.04.16 14:47 提问

#include
main()
{
int a,b,c,d,e,s,w,y1,y2,y3,year;
printf("请输入任意年、月、日（以空格隔开）\n");
scanf("%d%d%d",&a,&b,&c);
if((year%4==0 && year%100==0) || year%400==0)
{
s=a-1;
y1=s/4;
y2=s/100;
y3=s/400;
w=(s-y1+y2-y3)*365+(y1-y2+y3)*366+1;
if(b==1)
{c=31;

e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==2)
{c=28;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==3)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==4)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==5)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==6)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==7)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==8)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==9)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==10)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==11)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==12)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }

}
else

{
s=a-1;
y1=s/4;
y2=s/100;
y3=s/400;
w=(s-y1+y2-y3)*365+(y1-y2+y3)*366+1;
printf("请输入月份：");
scanf("%d",&b);
if(b==1)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==2)
{c=29;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==3)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==4)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==5)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==6)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==7)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==8)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==9)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==10)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==11)
{c=31;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }
if(b==12)
{c=30;
printf("请输入日期：");
scanf("%d",&c);
e=w+b+c;
printf("俩年份之间差%d天",&e); }

}

}

2个回答

qq423399099      2016.04.16 15:12

if((year%4==0 && year%100==0) || year%400==0) 应该改成if((year%4==0 && year%100!=0) || year%400==0)

qq423399099 printf("俩年份之间差%d天",&e);应该是printf("俩年份之间差%d天",e);

u012155923   2016.04.16 16:19