文章

10

粉丝

55

获赞

3

访问

2.9k

头像
日期累加 题解:跨年之后需要重新重新计算二月份天数,否则只能通过百分之五十
P1446 北京理工大学机试题
发布于2024年3月6日 11:10
阅读数 238

#include <bits/stdc++.h>
using namespace std;

struct node{
    int year;
    int month;
    int day;
}p;

int f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int m;
    int plus;
    int sum=0;
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d%d%d%d",&p.year,&p.month,&p.day,&plus);
        {
            if((p.year%400==0)||(p.year%4==0)&&(p.year%100!=0)) f[2]=29; else f[2]=28;
            sum=sum+p.day+plus;
            while(sum>f[p.month]){
                sum=sum-f[p.month];
     ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发