Calculate Date Difference
題目說明
<1124檢定考題>
程式從鍵盤輸入兩個相同年度的日期 (格式為 yyyy/mm/dd) ,日期前後順序不一定,
其合法範圍為 1970/01/01- 2024/05/31,從螢幕輸出這兩個日期相差幾天(需考慮潤年)。
規則:
(1) 若日期不為兩個相同年度,輸出「error」。
(2) 若日期不在合法範圍內,輸出「error」。
(3) 若日期不符合格式,輸出「error」。
輸入
從鍵盤輸入兩個相同年度的日期 (格式為 yyyy/mm/dd) ,日期前後順序不一定
其合法範圍為 1970/01/01- 2024/05/31
輸出
從螢幕輸出這兩個日期相差幾天(需考慮潤年)
sample input1
2024/05/01 2024/05/30
sample output1
29
sample input2
2023/12/31 2024/01/05
sample output2
error
sample input3
2022/1/03 2022/04/01
sample output3
error
Comments