PAT 乙级 1028

📅 发布时间:2026/7/7 13:40:47 👁️ 浏览次数:
PAT 乙级 1028
我压根就不知道这种日期的字符串可以直接比较。我写了几十行的 bool 比较写了半天仍旧是错家伙。本题如果没有讨论 k 0 的情况会显示格式错误。#includebits/stdc.h using namespace std; int main() { string s, s1, s2, birthday; string young 1813/09/06, old 2015/09/06; int n, k 0; cin n; for(int i 0; i n; i ) { cin s birthday; if(birthday 1814/09/06 birthday 2014/09/06) { k ; if(birthday young) s1 s; if(birthday old) s2 s; young max(birthday, young); old min(birthday, old); } } if(k 0) cout k; else cout k s2 s1 endl; return 0; }