#include #include #include #include using namespace std; struct runner { int finishTime; int paceTime; string name; }; void sort( runner runners[], int count ); void swap( runner &r1, runner &r2 ); void readInput(ifstream &in, runner runners[], int &racer); void print( ofstream &out, runner runners[], int racer ); int computeTotalSeconds( int hours, int minutes, int seconds ); const int NUMBEROFRACERS = 100; int main() { ifstream in; ofstream out; in.open("Race.txt"); out.open("summary.txt"); int racer = 0; runner runners[NUMBEROFRACERS]; readInput( in, runners, racer ); sort( runners, racer ); print( out, runners, racer ); in.close(); out.close(); return 0; } void sort( runner runners[], int count ) { for ( int pass=0; pass runners[check].finishTime ) { min = check; } } swap( runners[pass], runners[min] ); } } void swap( runner &r1, runner &r2 ) { runner tempRunner = r1; r1 = r2; r2 = tempRunner; } void readInput(ifstream &in, runner runners[], int &racer) { int distanceTenths; int hours; int minutes; int seconds; int totalSeconds; int secondsMile; double distance; char colon; string name; in.ignore( 200, ':' ); in >> distance; in.ignore( 200, '\n' ); in.ignore( 200, '\n' ); distanceTenths = distance * 10; //priming read getline( in, name, '\t' ); in >> hours >> colon >> minutes >> colon >> seconds; in.ignore( 200, '\n' ); while ( in ) { totalSeconds = computeTotalSeconds( hours, minutes, seconds ); secondsMile = 10 * ( (double)totalSeconds / distanceTenths ); if ( racer < NUMBEROFRACERS ) { runners[racer].name = name; runners[racer].finishTime = totalSeconds; runners[racer].paceTime = secondsMile; racer++; } //priming read getline( in, name, '\t' ); in >> hours >> colon >> minutes >> colon >> seconds; in.ignore( 200, '\n' ); } } int computeTotalSeconds( int hours, int minutes, int seconds ) { int totalSeconds; totalSeconds = hours * 3600 + minutes * 60 + seconds; return totalSeconds; } void print( ofstream &out, runner runners[], int racer ) { int paceMinute; int paceSecond; char colon = ':'; out << left << setw(20) << "Name" << right << setw(13) << "Time" << setw(15) << "Pace" << endl; for( int i=0; i<49; i++) out << "="; out <