#include <stdio.h>
//输入日期,计算这一天为这一年的第几天
int main()
{
//输入年月日
int year = 0;
scanf("%d", &year);
int month = 0;
scanf("%d", &month);
int day = 0;
scanf("%d", &day);
//定义变量,用于累加天数
int sum = 0;
//判断年份为闰年还是平年
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
{
//利用Switch语句,判断输入的月份
//并将天数加起来
//输入的日期+前一个月的天数 = 这一年的第几天
switch (month)
{
case 1:
sum += day;
break;
case 2:
sum += day + 31;
break;
case 3:
sum += day + 60;
break;
case 4:
sum += day + 91;
break;
case 5:
sum += day + 121;
break;
case 6:
sum += day + 152;
break;
case 7:
sum += day + 182;
break;
case 8:
sum += day + 213;
break;
case 9:
sum += day + 244;
break;
case 10:
sum += day + 274;
break;
case 11:
sum += day + 305;
break;
case 12:
sum += day + 335;
break;
}
printf("%d月%d日是%d年的第%d天\n", month,day, year, sum);
}
//平年情况
else
{
//利用Switch语句,判断输入的月份
//并将天数加起来
//输入的日期+前一个月的天数 = 这一年的第几天
switch (month)
{
case 1:
sum += day;
break;
case 2:
sum += day + 31;
break;
case 3:
sum += day + 59;
break;
case 4:
sum += day + 90;
break;
case 5:
sum += day + 120;
break;
case 6:
sum += day + 151;
break;
case 7:
sum += day + 181;
break;
case 8:
sum += day + 212;
break;
case 9:
sum += day + 243;
break;
case 10:
sum += day + 273;
break;
case 11:
sum += day + 304;
break;
case 12:
sum += day + 334;
break;
}
printf("%d月%d日是%d年的第%d天\n", month,day, year, sum);
}
return 0;
}