Advertisement
elitsa

Untitled

Jan 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. struct student
  7. {
  8. int fn;
  9. int problem;
  10. double points;
  11. bool out=0;
  12.  
  13. };
  14.  
  15.  
  16. bool areTheSame (student student1, student student2)
  17. {
  18. if (student1.fn==student2.fn && student1.problem==student2.problem && student1.points==student2.points)
  19. return true;
  20. return false;
  21. }
  22.  
  23.  
  24. student compareStudents (student student1, student student2)
  25. {
  26. if (student1.fn>student2.fn)
  27. return student1;
  28. else if(student2.fn>student1.fn) return student2;
  29. else if (student1.problem>student2.problem) return student1;
  30. else if (student2.problem>student1.problem) return student2;
  31. else if (student1.points>student2.points) return student1;
  32. else if (student2.points>student1.points) return student2;
  33. }
  34.  
  35.  
  36. int main ()
  37. {
  38. unsigned int n;
  39. student students[1000000];
  40. student minStudent;
  41. int i=0;
  42.  
  43. cin>>n;
  44.  
  45. for (int counter=0; counter<n; counter++)
  46. cin>>students[counter].fn>>students[counter].problem>>students[counter].points;
  47.  
  48.  
  49. while (i<n)
  50. {
  51. int f=0;
  52. while (students[f].out==1) f++;
  53.  
  54. minStudent.fn=students[f].fn;
  55. minStudent.problem=students[f].problem;
  56. minStudent.points=students[f].points;
  57.  
  58. for (int counter=0; counter<n; counter++)
  59. {
  60. if (f!=counter && students[counter].out!=1)
  61. {
  62. minStudent.fn=compareStudents(students[counter], students[f]).fn;
  63. minStudent.problem=compareStudents(students[counter], students[f]).problem;
  64. minStudent.points=compareStudents(students[counter], students[f]).points;
  65. }
  66. if (areTheSame(students[counter], minStudent)==1) students[counter].out=1;
  67. else students[f].out=1;
  68.  
  69. }
  70.  
  71. cout<<minStudent.fn<<" "<<minStudent.problem<<" "<<minStudent.points<<endl;
  72. i++;
  73. }
  74.  
  75.  
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement