#include #include #include #include using namespace std; void rewriteScore(const string&); int main() { ifstream fin("nfl_scores.txt"); string buffer; while (getline(fin,buffer) && buffer.size()) rewriteScore(buffer); } void rewriteScore(const string& buffer) { string temp, dummy, winner, loser; int winnerScore, loserScore; stringstream ss; ss.str(buffer); ss >> dummy >> winner >> temp; winner += ' '; winner += temp; ss >> temp; // look for a comma at the end of temp if (isalpha(temp[0]) or temp == "49ers") { winner += ' '; winner += temp; ss >> temp; } // remove the comma from the winner's score string temp.resize(temp.size()-1); winnerScore = stoi(temp); ss >> loser >> temp; loser += ' '; loser += temp; ss >> temp; if (isalpha(temp[0]) or temp == "49ers") { loser += ' '; loser += temp; ss >> temp; } loserScore = stoi(temp); ss.clear(); ss << winner << " over " << loser << ' ' << winnerScore << " to " << loserScore; cout << ss.str() << endl; } /* INPUT FILE 6-Sep Philadelphia Eagles 18, Atlanta Falcons 12 9-Sep Miami Dolphins 27, Tennessee Titans 20 9-Sep Minnesota Vikings 24, San Francisco 49ers 16 9-Sep Baltimore Ravens 47, Buffalo Bills 3 9-Sep Cincinnati Bengals 34, Indianapolis Colts 23 9-Sep Tampa Bay Buccaneers 48, New Orleans Saints 40 9-Sep New England Patriots 27, Houston Texans 20 9-Sep Jacksonville Jaguars 20, New York Giants 15 9-Sep Pittsburgh Steelers 21, Cleveland Browns 21 9-Sep Kansas City Chiefs 38, Los Angeles Chargers 28 9-Sep Washington Redskins 24, Arizona Cardinals 6 9-Sep Carolina Panthers 16, Dallas Cowboys 8 9-Sep Denver Broncos 27, Seattle Seahawks 24 9-Sep Green Bay Packers 24, Chicago Bears 23 10-Sep New York Jets 48, Detroit Lions 17 10-Sep Los Angeles Rams 33, Oakland Raiders 13 13-Sep Cincinnati Bengals 34, Baltimore Ravens 23 16-Sep New Orleans Saints 21, Cleveland Browns 18 16-Sep Kansas City Chiefs 42, Pittsburgh Steelers 37 16-Sep Miami Dolphins 20, New York Jets 12 16-Sep Los Angeles Chargers 31, Buffalo Bills 20 16-Sep Tampa Bay Buccaneers 27, Philadelphia Eagles 21 16-Sep Minnesota Vikings 29, Green Bay Packers 29 16-Sep Atlanta Falcons 31, Carolina Panthers 24 16-Sep Indianapolis Colts 21, Washington Redskins 9 16-Sep Tennessee Titans 20, Houston Texans 17 16-Sep Los Angeles Rams 34, Arizona Cardinals 0 16-Sep San Francisco 49ers 30, Detroit Lions 27 16-Sep Denver Broncos 20, Oakland Raiders 19 16-Sep Jacksonville Jaguars 31, New England Patriots 20 16-Sep Dallas Cowboys 20, New York Giants 13 */