题目:给出年月日,计算该日期是这一年的第几天
#include<stdio.h>
#include<stdbool.h>bool isLeapYear(int year) {return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}int dayOfYear(int year, int month, int day) {int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};if (isLeapYear(year)) {daysInMonth[1] = 29;}int totalDays = 0;for (int i = 0; i < month - 1; i++){totalDays += daysInMonth[i];}totalDays += day;return totalDays;}int main() {int year, month, day;printf("请输入年月日(格式为:年 月 日):");scanf_s("%d %d %d", &year, &month, &day);printf("该日期是这一年的第 %d 天\n", dayOfYear(year, month, day));return 0;
}