计算距离你的生日还有多久

#include
main()
{
 int i,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},b[13]={0};
 int year ,month,day,count1=0,count2=0,y,d,m;
 char oo[20];
  printf("请输入你的名字/n");
  gets(oo);
  printf("输入你的18位身份证号码:/n");
  scanf("%*6d%4d%2d%2d%*4d",&y,&m,&d);
  printf("输入今天的日期:/n");
  scanf("%d%d%d",&year,&month,&day);
  for(i=2;i<13;i++)
   b[i]=b[i-1]+a[i-1];
  count1=b[month]+day;
  if((year%4==0)&&(year%100!=0)||(year%400==0))
   count1+=1;
  count2=b[m]+d-count1;
  if(count2<0)
  {
   if((year%4==0)&&(year%100!=0)||(year%400==0))
    count2+=366;
   else if((((year+1)%4==0)&&((year+1)%100!=0)||((year+1)%400==0))&&(m>2))
    count2+=366;
   else
    count2+=365;
  }
  printf("-----------------------------------------/n");
  printf("%s你好/n",oo);
  printf("你的生日是%d年%d月%d日/n",y,m,d);
  printf("这是%d年的第%d 天/n",year,count1);
  printf("距离你的生日还有%d天/n",count2);
}

你可能感兴趣的:(计算距离你的生日还有多久)