8 条题解
-
0
// 处理每个月的天数 int days_in_month;
switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days_in_month = 31; break; case 4: case 6: case 9: case 11: days_in_month = 30; break; case 2: // 判断是否是闰年 if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { days_in_month = 29; } else { days_in_month = 28; } break; default: days_in_month = 0; // 无效的月份 break; }
printf("%d\n", days_in_month); return 0;
-
0
#include<stdio.h> int main() { int year, month, days; scanf("%d %d", &year, &month); switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12:days = 31; break; case 4: case 6: case 9: case 11:days = 30; break; case 2: if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) days = 29; else days = 28; break; } printf("%d",days); return 0; }
-
0
#include<stdio.h> int main(){ int x,y;1<=y&&y<=12; scanf("%d %d",&x,&y); switch(y){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: printf("31");break; case 4: case 6: case 9: case 11: printf("30");break; case 2: if(x%40&&x%100!=0||x%4000) {printf("29"); }else printf("28");break; } return 0; }
- 1
信息
- ID
- 43
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 4495
- 已通过
- 1222
- 上传者