A pythonic answer:
from datetime import date
try:
today = date(*map(int,input().split('-')))
print((today - date(2017,1,1)).days + 1)
except ValueError:
print(-1)
If you really hate import
, you can search for datetime.py
in your computer, read it, then define the class date
by yourself. :)
我今天发现,C++ 的
<iomanip>
里也有个读取时间的东西get_time
,233333然而这样读完之后并不能直接加减运算,想做到类似的事还得等c++20实装
chrono::year_month_day
ㄟ( ▔, ▔ )ㄏ
太难了233