#include <stdio.h>
struct date
{
int year;
int month;
int day;
}a;
main()
{
char ch1,ch2;
int days;
printf("Input date(YYYY-MM-DD):");
scanf("%d%c%d%c%d",&a.year,&ch1,&a.month,&ch2,&a.day);
while((ch1!=ch2)||(ch1!=' '&&ch1!='/'&&ch1!='-')||(a.month<=0||a.month>=13))
{
printf("Input Error!/n");
scanf("%d%c%d%c%d",&a.year,&ch1,&a.month,&ch2,&a.day);
}
switch(a.month)
{
case 1:days=a.day;break;
case 2:days=a.day+31;break;
case 3:days=a.day+28+31;break;
case 4:days=a.day+28+31+31;break;
case 5:days=a.day+28+31+31+30;break;
case 6:days=a.day+28+31+31+30+31;break;
case 7:days=a.day+28+31+31+30+31+30;break;
case 8:days=a.day+28+31+31+30+31+30+31;break;
case 9:days=a.day+28+31+31+30+31+30+31+31;break;
case 10:days=a.day+28+31+31+30+31+30+31+31+30;break;
case 11:days=a.day+28+31+31+30+31+30+31+31+30+31;break;
case 12:days=a.day+28+31+31+30+31+30+31+31+30+31+30;break;
}
if(a.year%4==0&&a.year%100!=0||a.year%400==0)
days=days+1;
if(ch1==' ') printf("%d/%d/%d is %dth days in %d year./n",a.year,a.month,a.day,days,a.year);
else printf("%d%c%d%c%d is %dth days in %d year./n",a.year,ch1,a.month,ch2,a.day,days,a.year);
}