酷代码 AI
菜单
服务商
DeepSeek字节豆包讯飞星火
更多选项

C语言实现:计算指定日期在本年中是第几天

```c #include <stdio.h> struct Date { int year; int month; int day; }; int days(struct Date date) { int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int dayCount = 0; for (int i = 0; i < date.month - 1; i++) { dayCount += daysInMonth[i]; } dayCount += date.day; if ((date.year % 400 == 0 || (date.year % 4 == 0 && date.year % 100!= 0)) && date.month > 2) { dayCount++; } return dayCount; } int main() { struct Date date; scanf("%d %d %d", &date.year, &date.month, &date.day); int result = days(date); printf("%d\n", result); return 0; } ``` ######[AI写代码神器 | 270点数解答 | 2024-10-17 07:12:43]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]