题解 | #获得月份天数#

获得月份天数

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语言刷题题目

全部评论

相关推荐

05-26 22:25
门头沟学院 Java
Java小肖:不会是想叫你过去把你打一顿吧,哈哈哈
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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