# include<iostream> # include<string> # include<algorithm> # include<stdio.h> # include<vector> using namespace std; struct student { int hao,h,w; string name; }stu; bool LessSort(student a,student b) { return (a.hao<b.hao); } int main() { int n,xh,xm,he,we; cin>>n; vector<student> v; for(int i=0;i<n;i++) { cin>>stu.hao>>stu.name>>stu.h>>stu.w; v.push_back(stu); } sort(v.begin(),v.end(),LessSort); int count=0,maxh,maxw,flag=1; string maxname; for(int i=0;i<n;i=i+1) { if(i==0) { maxh = v[i].h; maxname = v[i].name; maxw = v[i].w; } else { if(v[i].hao==v[i-1].hao) { if(v[i].h>v[i-1].h) { maxh = v[i].h; maxname = v[i].name; maxw = v[i].w; } } else { printf("%06d ",v[i-1].hao); cout<<maxname<<" "<<maxh<<" "<<maxw<<endl; maxh = v[i].h; maxname = v[i].name; maxw = v[i].w; if(i==n-1) { printf("%06d ",v[i-1].hao); cout<<maxname<<" "<<maxh<<" "<<maxw<<endl; } } } } return 0; }
#include<iostream> using namespace std; class Student { public: Student() { number=0; name; mark=0; } void set_student(); void show_student(); friend void find(Student stu[],int q); private: int number; char name[10]; int mark; }; void Student::set_student() { cin>>number; cin>>name; cin>>mark; } void Student::show_student() { cout<<number<<' '<<name<<' '<<mark<<endl; } void find(Student stu[],int q) { int min=101,w; for(int i=0;i<q;i++) { if(stu[i].mark<min) { w=i; min=stu[i].mark; } } stu[w].show_student(); } int main() { int n; Student stu[10]; while(cin>>n) { if(n==0)break; for(int i=0;i<n;i++) { stu[i].set_student(); } find(stu,n); } return 0; }