#include "stdio.h" int year,mouth,day,sum=0; check(int month) { if(month>12||month<1) { printf(" the mouth is ill,enter it again\n"); scanf("%d",&mouth); } else { return; } check(mouth); } checkday(int date,int mon,int lp) { if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12) { if(date>31||date<1) { printf(" the day is ill,enter it again\n"); scanf("%d",&day); } else { return; } } else if(mon==2) { if((date>29||date<1)&&lp) { printf(" the day is ill,enter it again\n"); scanf("%d",&day); } else if((date>28||date<1)&&!lp) { printf(" the day is ill,enter it again\n"); scanf("%d",&day); } else { return; } } else { if(date>30||date<1) { printf(" the day is ill,enter it again\n"); scanf("%d",&day); } else { return; } } checkday(day,mon,lp); } main() { int leap=0; printf("enter the date\n"); scanf("%d%d%d",&year,&mouth,&day); if(year%400==0||(year%4==0&&year%100!=0)) leap=1; check(mouth); checkday(day,mouth,leap); switch(mouth) { case 1: sum=0;break; case 2: sum=31;break; case 3: sum=59;break; case 4: sum=90;break; case 5: sum=120;break; case 6: sum=151;break; case 7: sum=181;break; case 8: sum=212;break; case 9: sum=243;break; case 10: sum=273;break; case 11: sum=304;break; case 12: sum=334;break; default:break; } sum+=day; if(leap&&mouth>2) sum+=1; printf("the date is the %d days of this year",sum); }