#29376: 為啥不行


milk_wu (milk(訂閱訂起來))

學校 : 新北市立中山國中
編號 : 183114
來源 : [163.20.41.252]
最後登入時間 :
2022-09-28 17:33:31
a263. 日期差幾天 -- 板橋高中練習題 | From: [49.216.82.103] | 發表日期 : 2022-02-20 17:36

請位哪裡錯   

#include<iostream>

 

    using namespace std;

 

 

 

    int main(){

    int y, m, e, y2, m2, e2, s;

    cin >> y >> m >> e >> y2 >> m2 >>e2;

    s = y - y2;

    if (!(y % 400) || (!(y % 4) && (y % 100)))

    {

        if (s > 0)

    {

    cout << ((e - e2) + 365 * s) + 1 <<endl;

    }

    else

    {

        cout << (e - e2) + 1 <<endl;

    }

    }

    else

    {

        if (s > 0)

    {

    cout << ((e - e2) + 365 * s) <<endl;

    }

    else

    {

        cout << (e - e2) <<endl;

    }

    }

 

    return 0;

 

    }

 
#29378: Re:為啥不行


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a263. 日期差幾天 -- 板橋高中練習題 | From: [39.10.130.143] | 發表日期 : 2022-02-20 22:43

請位哪裡錯   

#include

 

    using namespace std;

 

 

 

    int main(){

    int y, m, e, y2, m2, e2, s;

    cin >> y >> m >> e >> y2 >> m2 >>e2;

    s = y - y2;

    if (!(y % 400) || (!(y % 4) && (y % 100)))

    {

        if (s > 0)

    {

    cout << ((e - e2) + 365 * s) + 1 <<endl;

    }

    else

    {

        cout << (e - e2) + 1 <<endl;

    }

    }

    else

    {

        if (s > 0)

    {

    cout << ((e - e2) + 365 * s) <<endl;

    }

    else

    {

        cout << (e - e2) <<endl;

    }

    }

 

    return 0;

 

    }


1. 多筆測資

2. 閏年的計算有問題

3. 兩個日期的順序似乎不一定

 
ZeroJudge Forum