Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct student
- {
- int fn;
- int problem;
- double points;
- bool out=0;
- };
- bool areTheSame (student student1, student student2)
- {
- if (student1.fn==student2.fn && student1.problem==student2.problem && student1.points==student2.points)
- return true;
- return false;
- }
- student compareStudents (student student1, student student2)
- {
- if (student1.fn>student2.fn)
- return student1;
- else if(student2.fn>student1.fn) return student2;
- else if (student1.problem>student2.problem) return student1;
- else if (student2.problem>student1.problem) return student2;
- else if (student1.points>student2.points) return student1;
- else if (student2.points>student1.points) return student2;
- }
- int main ()
- {
- unsigned int n;
- student students[1000000];
- student minStudent;
- int i=0;
- cin>>n;
- for (int counter=0; counter<n; counter++)
- cin>>students[counter].fn>>students[counter].problem>>students[counter].points;
- while (i<n)
- {
- int f=0;
- while (students[f].out==1) f++;
- minStudent.fn=students[f].fn;
- minStudent.problem=students[f].problem;
- minStudent.points=students[f].points;
- for (int counter=0; counter<n; counter++)
- {
- if (f!=counter && students[counter].out!=1)
- {
- minStudent.fn=compareStudents(students[counter], students[f]).fn;
- minStudent.problem=compareStudents(students[counter], students[f]).problem;
- minStudent.points=compareStudents(students[counter], students[f]).points;
- }
- if (areTheSame(students[counter], minStudent)==1) students[counter].out=1;
- else students[f].out=1;
- }
- cout<<minStudent.fn<<" "<<minStudent.problem<<" "<<minStudent.points<<endl;
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement