// examScores1.cpp
// Given a sequence of exam scores as
// command-line arguments, displays table
// of exam scores and curved scores.

#include <iostream>
#include <cstdio>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{
   if (argc < 2)  {
      cout << "Given a sequence of exam scores ";
      cout << "entered as command line arguments," << endl;
      cout << "this program will curve them up ";
      cout << "by raising the highest to 100 and " << endl;
      cout << "raising all others by the same amount." << endl;
      return 1;
   }  // if

   // Named constants:
   const int NUMBER_OF_SCORES = argc - 1;
   const int COLUMN_WIDTH = 5;

   // Declare array which will store exam scores:
   int scores[NUMBER_OF_SCORES];

   // Read scores into array and determine maximum:
   int maximumScore = 0;   // Because no score is less than 0,
                           // the maximum score >= 0.

   for ( int i = 0; i < NUMBER_OF_SCORES; i++ )  {
      if ( ! sscanf(argv[i+1], "%d", &scores[i]) )  {
         cout << "Scores must be integers only." << endl;
         return 1;
      }  // if

      if ( scores[i] > maximumScore )
         maximumScore = scores[i];
   } // for i

   // Determine how many points to curve up all scores:
   int curveUp = 100 - maximumScore;

   // Output table of original scores and curved scores:
   for ( int i = 0; i < NUMBER_OF_SCORES; i++ )  {

      // Print original score in a right-justified column:
      cout << setw(COLUMN_WIDTH) << scores[i];

      // Calculate curved score;
      int curvedScore = scores[i] + curveUp;

      // Print curved score in a right-justified column;
      cout << setw(COLUMN_WIDTH) << curvedScore << endl;
   } // for i

   return 0;
}  // function main