question: Enter a certain date of the year, Judge this day is the first days of the year.
/* Procedure analysis: Take March 5 as an example, should first add up the first two months,
and then add 5 days that the first days of this year, special circumstances, leap years and enter a
month greater than 3 o'clock to consider an additional day.
* *
#include <stdio.h>
int main () {
int day, month, year, sum, Leap;
printf ("\nplease input year,month,day\n");
scanf ("%d%d%d", &year,&month,&day);
Switch (month) { //first calculates the total number of days before month of month
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:printf ("Data error!"); break;
sum = sum + day; Plus days of the day
if (year%400==0| | (year%4==0&&year%100!=0)) { //Judge is leap year
leap = 1;
} else{
leap = 0;
}
if (leap = = 1&&month > 2) { //If it is a leap year and the month is greater than 2, total plus 1 days
sum++;
}
printf ("It is the%dth day.", sum);
}