题解 | #今年的第几天?#

今年的第几天?

https://www.nowcoder.com/practice/ae7e58fe24b14d1386e13e7d70eaf04d

#include <stdio.h>
int main(){
    int Month[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int year, month, day;
    while (scanf("%d %d %d", &year, &month, &day) != EOF){
        int total = 0;
        if(month == 1){
            printf("%d\n", day);
        }
        else{
            for (int i = 0; i < month - 1; ++i) {
                total += Month[i];
            }
            total += day;
            if(month > 2 && year % 100 != 0 && year % 4 == 0 || year % 400 == 0){
                total++;
            }
            printf("%d\n", total);
        }
    }
    return 0;
}

全部评论

相关推荐

07-01 17:14
中北大学 Java
兄弟们是真是假
牛客46374834...:我在boss上投java岗从来没成功过
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-03 17:37
点赞 评论 收藏
分享
重生我想学测开:嵌入式的问题,我准备入行京东外卖了
点赞 评论 收藏
分享
06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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