题解 | #前天是哪天#

前天是哪天

https://ac.nowcoder.com/acm/contest/19304/Q

#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%4d-%2d-%2d",&a,&b,&c);
    int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    if(a%4==0&&a%100!=0||a%400==0)m[2]++;
    if(c>=3)c-=2;
    else if(b!=1)
    {
        b--;
        c=m[b]+c-2;
    }
    else 
    {
        a--;
        b=12;
        c=31+c-2;
    }printf("%4d-%02d-%02d",a,b,c);
}

全部评论

相关推荐

爱睡觉的冰箱哥:你是我今晚见过的最美的牛客女孩
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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