Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
145488 傻逼小安 09闰年第n个月有多少天 C Wrong Answer 0 MS 204 KB 816 2026-01-25 15:45:32

Tests(0/10):


Code:

#include <stdio.h> // 判断闰年函数 int is_leap_year(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } // 计算月份天数 int get_days(int year, int month) { int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // 下标0占位,1-12对应月份 if (month == 2 && is_leap_year(year)) return 29; // 闰年2月 else return days[month]; // 其他月份直接返回数组值 } int main() { int year, month; printf("输入年份和月份(格式:年,月):"); scanf("%d,%d", &year, &month); // 按逗号分隔输入 if (month < 1 || month > 12) { printf("无效月份!\n"); return 1; // 错误退出 } printf("%d\n", get_days(year, month)); return 0; }


Run Info:

------Input------
3
------Answer-----
31
------Your output-----
输入年份和月份(格式:年,月):无效月份!