1028 人口普查 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805293282607104
#include <iostream> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; int main() { int n; char chr[6],maxchr[6],minchr[6]; int year,month,day,length,count=0; int maxlength=20140907,minlength=18140905; cin>>n; for(int i=0;i<n;i++) { scanf("%s %d/%d/%d",chr,&year,&month,&day); length=year*10000+month*100+day; if(length>=18140906&&length<=20140906){ count++; if(length<maxlength) { strcpy(maxchr,chr); maxlength=length; } if(length>minlength) { strcpy(minchr,chr); minlength=length; } } } if(count) cout<<count<<" "<<maxchr<<" "<<minchr<<endl; else cout<<"0"<<endl; return 0; }
原文地址:https://www.cnblogs.com/jianqiao123/p/12247139.html
时间: 2024-10-11 12:00:49