HUST-最小年龄的三个职工
作者:互联网
1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 #include <string> 5 #include <vector> 6 #include <algorithm> 7 using namespace std; 8 struct Node{ 9 int id; 10 char chr[13]; 11 int age; 12 }node[35]; 13 bool cmp(Node a,Node b) 14 { 15 if(a.age!=b.age) return a.age<b.age; 16 if(a.id!=b.id) return a.id<b.id; 17 return strcmp(a.chr,b.chr)<0; 18 } 19 vector<Node> vec; 20 int main() 21 { 22 int n; 23 while(cin>>n) 24 { 25 for(int i=0;i<n;i++) 26 { 27 cin>>node[i].id>>node[i].chr>>node[i].age; 28 vec.push_back(node[i]); 29 } 30 sort(vec.begin(),vec.end(),cmp); 31 int num=n<3?n:3; 32 for(int i=0;i<num;i++) 33 cout<<vec[i].id<<" "<<vec[i].chr<<" "<<vec[i].age<<endl; 34 } 35 return 0; 36 }
标签:node,Node,职工,int,age,HUST,最小,vec,include 来源: https://www.cnblogs.com/jianqiao123/p/14370338.html