题解 | #获得月份天数#

获得月份天数

https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6

#include <stdio.h>

int main() {
    int year, month = 0;
    int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    while (scanf("%d %d", &year, &month) != EOF) {
        int day = days[month - 1];
        if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0)) {
            if (month == 2)
                day++;
        }
        printf("%d\n", day);
    }
    return 0;
}

c语言刷题 文章被收录于专栏

c语言刷题题目

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-07 13:15
点赞 评论 收藏
分享
下个早班:秒挂就是不缺人
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 11:22
怎么这么多逆天求职者,救救我救救我救救我😭
flmz_Kk:哈哈哈哈哈哈,这么多求职者,肯定有那一两个逆天的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务