Your sorting algorithm needs rethink. If you are not permitted to use
std::sort(), then I recommend you use one of:
http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/insertion-sort/
http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/selection-sort/
You can also use a
bubble sort, if you must, but these other two will out-perform it on your list of students, and are easier to understand.
After you sort the student grades, highest to lowest, then you know you can simply ignore the last grade (since it is the lowest). There's the trick. Sort normally -- who cares which grade is what -- so long as they all get sorted properly.
Only
after you have sorted do you worry about 'dropping' a quiz score -- the very last one. Hence, when it is time to compute the average, treat the student
quiz[] array as if it has only four elements (even though it actually has five) -- that is, ignore the last, lowest score.
Also, your struct is misnamed-- it represents a single
student, right? Hence, the struct name should be singular:
1 2 3 4
|
struct student
{
...
};
|
Now when you have a list of students, you can name it as such:
1 2 3
|
int main()
{
student students[ 30 ];
|
Hope this helps.