/*note:your Choice is C IDE*/#include"stdio.h"voidMain () {intY,m,d;//year, month, day intcr,ds=0I//CR: The variable that determines whether it is a leap year, is 1, no 0;ds: The sum of the days; I is a loop variable Charrun[ A] = { to, in, to, -, to, -, to, to, -, to, -, to};//number of days per month for leap years Charping[ A] = { to, -, to, -, to, -, to, to, -, to, -, to};//common year number of days of the monthprintf"Please enter the year you want to inquire: \ n"); scanf ("%d", &y);//Enter YearCR = y%4==0&&y% -!=0|| y% -==0;//determines whether a leap year, is 1, no is 0 Do{printf ("Please enter month: \ n"); scanf ("%d", &m);//Enter Month if(m<0|| M> A){//determine if there are any input errorsprintf"input wrong, please re-enter! \ n");} } while(m<0|| M> A);//wrong re-entry Do{printf ("Please enter the date: \ n"); scanf ("%d", &d);//Enter Date if(d> to){//determine if you have entered a number greater than 31stprintf"input wrong, please re-enter! (Up to 31 days in one months) \ n"); }Else if(d>run[m-1]&&cr==1)//determines whether a number of days in a leap year is within the maximum number of days in the month{printf ("%d months up to%d days, please re-enter! \ n", m,run[m-1]); }Else if(d>ping[m-1]&&cr==0)//determine whether common year days are within the maximum number of days of the month{printf ("%d months up to%d days, please re-enter! \ n", m,ping[m-1]); } } while((d>run[m-1]&&cr==1)|| (d>ping[m-1]&&cr==0)); if(CR = =1){//calculate the total number of days in a leap year for(i=0; i<m-1; i++) {DS+=Run[i]; } }Else{//calculates the total number of days in the year for a common year for(i=0; i<m-1; i++) {DS+=Ping[i]; } DS+ = D;//plus the number of days in the monthprintf"%d%d months%d days is the%d day of the year! ", Y,m,d,ds); } }
C language-Enter the year, month, and day to figure out the day of the year