1028 人口普查 (20 分)

// 首先创建一个结构体,再创建三个结构体变量,设定好边界,记录合格人数,进行比较,输出。
#include <iostream> #include <algorithm> using namespace std; struct s { string name, bir; } a, young, old; int main() { int n, cnt = 0; string down = "1814/09/06", up = "2014/09/06"; young.bir = down; old.bir = up; cin >> n; while (n--) { cin >> a.name >> a.bir; if (!(a.bir >= down && a.bir <= up)) continue; cnt++; if (young.bir < a.bir) young = a; if (old.bir > a.bir) old = a; } if (cnt) cout << cnt << ' ' << old.name << ' ' << young.name << endl; else cout << cnt << endl; return 0; }
原文地址:https://www.cnblogs.com/Hk456/p/10764948.html