#include"stdio.h"voidMain () {/*year month months month1 backup month Day Day1 backup total number of days used to receive the number of days in the month, D1 the number of days that the month was backed up. s calculates the total number of days of the month before the current month sum of days sum*/ intyear,month,month1,day,day1,d1,sum=0, s=0; printf ("Please enter the year:"); scanf ("%d",&Year ); Fflush (stdin); Do{printf ("Please enter the month:"); scanf ("%d",&month); Fflush (stdin); if(month<1|| Month> A)//prompt for incorrect input{printf ("you entered the error \ n"); } } while(month<1|| Month> A);//determine if the input month is incorrect//1 3 5 7 8//4 6 9 eachMonth1=month;//number of months to backupmonth--;//month--: minus the current month total, calculated, the total number of days in the month is not counted, (January 28, January total days 31 days do not count in) for(; month>=1; month--) { if(month==1|| month==3|| month==5|| month==7|| month==8|| month==Ten|| month== A) { Day= to; }Else if(month==4|| month==6|| month==9|| month== One) { Day= -; }Else if(month==2) { if(year%4==0&&year% -==0|| year% -==0) { Day= -; }Else{ Day= in; }} s=s+Day ; }d1=Day ; Do{printf ("Please enter the day:"); scanf ("%d",&Day ); Fflush (stdin); Day1=Day ; if(day1<1|| Day1>d1) printf ("you entered the error \ n"); } while(day1<1|| Day1>D1); Sum=day1+s;//Total days Expressionprintf"%d months%d days is %d%d years", month1,day1,year,sum); }
Enter the day of the month, the days of the year when calculated