The code in BLUE it is where i change/add. The min_element and max_element is a function that return the maximum and minimum value.
// Gymnastics Competition Problem
// Laura Ade
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
#include <iomanip>
using std::setprecision;
#include <algorithm> // algorithm definitions
using std::max_element;
using std::min_element;
int main()
{
double score; // individual judge's score
double subtotal; // includes min and max scores
double final; // final score
int scoreCounter;// number of scores to be entered next
<em>double array[7];]// create an array to hold the score enter by user
int array_size = 7;</em>// the size of the array
subtotal = 0; // initialize final
scoreCounter = 1; // initialize loop counter
// Processing Phase
while ( scoreCounter <= 7 ){ // loop 8 times
cout << "Enter individual judge's score: "; // prompt for input
cin >> score; // read score from user
array[scoreCounter-1] = score;
subtotal = subtotal + score; // add score to subtotal
scoreCounter = scoreCounter + 1; // add 1 to counter
}
// Termination Phase
double max = *max_element( array, array+array_size);
double min =*min_element( array, array+array_size);
final = subtotal - max - min;// drop highest & lowest score
// Display Result
cout << "Final score is " << final << endl;
return 0; // indicate program ended successfully
}
<< moderator edit: added [code][/code] tags >>