该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
int main()
{
int i,j,k,t,m,a,b,c=0;
int x,y,z,n;
printf ("请按下面格式输年-月-日\n");
printf("请输入现在年月日:\n");
scanf ("%d-%d-%d",&i,&j,&k);
printf("请输入出生年月日:\n");
scanf("%d-%d-%d",&x,&y,&z);
n=i-x+1;
printf("你的年龄是:%d\n",n);
switch(j)
{
case 1:m=k;break;
case 2:m=31+k;break;
case 3:m=59+k;break;
case 4:m=90+k;break;
case 5:m=120+k;break;
case 6:m=151+k;break;
case 7:m=181+k;break;
case 8:m=212+k;break;
case 9:m=243+k;break;
case 10:m=273+k;break;
case 11:m=304+k;break;
case 12:m=334+k;break;
}
switch(y)
{
case 1:a=z;break;
case 2:a=31+z;break;
case 3:a=59+z;break;
case 4:a=90+z;break;
case 5:a=120+z;break;
case 6:a=151+z;break;
case 7:a=181+z;break;
case 8:a=212+z;break;
case 9:a=243+z;break;
case 10:a=273+z;break;
case 11:a=304+z;break;
case 12:a=334+z;break;
}
for(b=x;b<=i;b++)
{
if (b%400==0)//(b%4==0&&b%100!=0)
c=c+1;
if(y<2)
c=c-1;
if(j<2)
c=c+1;
}
t=(i-x)*365+m-a+c;printf("出生到现在的天数:%d",t); return 0;
}