I'm currently working on a program that calculate scores and show the ranks.
It works like this:
1) Input the 5 short forms of the names and their 5 scores.
E.g.
A 100 20 60 70 80
B 75 80 80 80 85
C 60 60 65 70 80
D 80 90 90 90 90
E 5 65 70 75 75
2) Delete each person's highest and lowest scores, then add up the remaining 3 scores.
E.g.
A 100(deleted) 80(add) 70(add) 60(add) 20(deleted)
Score of A=80+70+60=210
3) Rank the 1st, 2nd and 3rd. If two scores are the same, the person who got their scores entered 1st wins.
E.g.
First - D
Second - B
Third - A
**E's score is entered after A
My code is supposed to do these, but the input terminated when I entered 3 people and the output is also not correct. Please help me with it! Thanks a lot!
Consider using a std::vector<Person>. std::sort can sort such array according to the Person::total.
1 2 3 4 5
class Person {
char name;
std::vector<unsignedint> scores;
unsignedint total;
};
Remember though the initial assignment: "If two scores are the same, the person who got their scores entered 1st wins." Therefore, std::stable_sort is more to the point than std::sort.