Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  2015 10 2
Language: C/C++
Code:
#include<stdio.h>
int main()
{int n=9112,t,y,y1,m,d,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
while(1){
 scanf("%d%d%d",&y,&m,&d);
 if(y<0)break;
 n=9112+d;
 t=m>2;          
 while(n>366)
 {y1=(y++)+t;
  n-=365+(y1%4==0&&y1%100||y1%400==0);
 }
 while(n)
 {if(m==2)a[2]=28+(y%4==0&&y%100||y%400==0);
  if(n>a[m])
  {n-=a[m]; 
   if(m==12){m=1; y++;}
   else m++;  
  }
  else {d=n; n=0;} 
 }
printf("%d %d %dn",y,m,d);
}
return 0;
}
          
Comments: