当前位置:网站首页>B1028 census
B1028 census
2022-07-27 05:20:00 【Ye Chen】
1028 The census (20 branch )
A census was conducted in a town , Got all the residents' birthdays . Now please write a program , Find out the oldest and youngest people in town .
Make sure that every date you enter is legal , But it's not necessarily reasonable —— Suppose there's no more than 200 Old man , And today is 2014 year 9 month 6 Japan , So over 200 Birthday and unborn birthday are unreasonable , It should be filtered out .
Input format :
The input gives a positive integer on the first line N, The value is (0,10 Of 5 Power ]; And then N That's ok , Each line gives 1 Personal name ( By no more than 5 A string of English letters )、 And press yyyy/mm/dd( That is the year / month / Japan ) Birthday given in format . The title ensures that the oldest and youngest people are not tied .
Output format :
Output the number of valid birthdays in order in one line 、 The names of the oldest and youngest people , Separated by spaces .
sample input
5
John 2001/05/12
Tom 1814/09/06
Ann 2121/01/30
James 1814/09/05
Steve 1967/11/20
sample output
3 Tom John
Topic analysis :
- After creating the structure, it is very simple
The code is as follows :
#include<bits/stdc++.h>
using namespace std;
struct people{
string name;
int old;
}p[100100];
int main(){
int n,count=0;
string s;
cin>>n;
for(int i=0;i<n;i++){
cin>>p[i].name>>s;
p[i].old=(s[0]-'0')*10000000+(s[1]-'0')*1000000+(s[2]-'0')*100000+(s[3]-'0')*10000+(s[5]-'0')*1000+(s[6]-'0')*100+(s[8]-'0')*10+(s[9]-'0');
if(p[i].old<=20140906&&20140906-p[i].old<=2000000){
count++;
}
}
if(count==0){
cout<<"0"<<endl;
return 0;
}
int max=0,min=100000000;
for(int i=0;i<n;i++){
if(p[i].old<=20140906&&20140906-p[i].old<=2000000){
if(p[i].old<min){
min=p[i].old;
}
if(p[i].old>max){
max=p[i].old;
}
}
}
for(int i=0;i<n;i++){
if(min==p[i].old){
min=i;
}
if(max==p[i].old){
max=i;
}
}
cout<<count<<" "<<p[min].name<<" "<<p[max].name<<endl;
}
边栏推荐
- Demo of throttling function -- regular expression matching
- The interface can automatically generate E and other asynchronous access or restart,
- Detailed explanation of pointer constant and constant pointer
- OFDM 16 lecture 2-ofdm and the DFT
- Bean的生命周期&&依赖注入*依赖自动装配
- JVM上篇:内存与垃圾回收篇--运行时数据区四-程序计数器
- B1021 个位数统计
- Event
- Use of collection framework
- B1028 人口普查
猜你喜欢

JVM上篇:内存与垃圾回收篇十一--执行引擎

Detailed description of binary search tree

JDBC API 详解

Advantages of smart exhibition hall design and applicable industry analysis

Gradio quickly builds ml/dl Web Services

34. 分析flexible.js

B1021 single digit statistics

Typescript details

JVM Part 1: memory and garbage collection part 5 -- runtime data area virtual machine stack

JVM Part 1: memory and garbage collection part 12 -- stringtable
随机推荐
[acwing] solution to the 61st weekly match
B1023 组个最小数
Detailed description of binary search tree
《Robust and Precise Vehicle Localization based on Multi-sensor Fusionin Diverse City Scenes》翻译
B1031 查验身份证
LocalDateTime和ZonedDateTime
整合SSM
Advantages of smart exhibition hall design and applicable industry analysis
Static and final keyword learning demo exercise
Complete Binary Tree
JVM Part 1: memory and garbage collection part 12 -- stringtable
What is the future development direction of software testing engineers?
Domestic mainstream ERP software market
34. Analyze flexible.js
实用小工具: Kotlin 代码片段
Quoted popular explanation
JVM上篇:内存与垃圾回收篇十一--执行引擎
B1021 single digit statistics
JVM Part 1: memory and garbage collection -- runtime data area 4 - program counter
Introduction to Web Framework