题解 | #日期类#

日期类

https://www.nowcoder.com/practice/130aa2d7d1f5436b920229dca253893b

#include <stdio.h>

int main(){
    int n;
    int list1[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int year,month,day;
        scanf("%d %d %d",&year,&month,&day);
        day++;
        if (day>list1[month]){
            day=day-list1[month];
            month++;
        }
        if (month>12){
            year++;
            month=1;
        }
        printf("%4d-%02d-%02d\n",year,month,day);
    }
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 12:22
点赞 评论 收藏
分享
屌丝逆袭咸鱼计划:心态摆好,man,晚点找早点找到最后都是为了提升自己好进正职,努力提升自己才是最关键的😤难道说现在找不到找的太晚了就炸了可以鸡鸡了吗😤早实习晚实习不都是为了以后多积累,大四学长有的秋招进的也不妨碍有的春招进,人生就这样
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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