#include #include #include #include using namespace std; int main() { ifstream in; ofstream out; in.open("Race.txt"); out.open("summary.txt"); double distance; //this is the distance of the race int hours; int minutes; int seconds; int distanceTenths; int totalSeconds; int secondsMile; int paceMinute; int paceSecond; int racer = 0; const int NUMBEROFRACERS = 100; int totalTime[NUMBEROFRACERS]; int paceTime[NUMBEROFRACERS]; char colon; string name; string names[NUMBEROFRACERS]; 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' ); out << "Name" << '\t' << "Time" << '\t' << "Pace" << endl; while ( in ) { totalSeconds = hours * 3600 + minutes * 60 + seconds; secondsMile = 10 * ( (double)totalSeconds / distanceTenths ); if ( racer < NUMBEROFRACERS ) { names[racer] = name; totalTime[racer] = totalSeconds; paceTime[racer] = secondsMile; racer++; } //priming read getline( in, name, '\t' ); in >> hours >> colon >> minutes >> colon >> seconds; in.ignore( 200, '\n' ); } for ( int i = 0; i < racer; i++) { paceMinute = paceTime[i] / 60; paceSecond = paceTime[i] % 60; out << names[i] << " " << totalTime[i]/3600 << ':' << setfill('0') << setw(2) << (totalTime[i]%3600)/60 << ":" << setw(2) << (totalTime[i]%3600)%60 << setfill(' ') << " " << paceMinute << colon << setfill('0') << setw(2) << paceSecond << setfill(' ') << endl; } in.close(); out.close(); return 0; }