#include #include #include #include #include #include using namespace std; struct team { int rank; string name; string shortName; int won; int tied; int lost; int goalsreceived; int goalsshot; int order; bool operator <(const team& otherTeam) const { if (won*3 + tied < otherTeam.won*3 + otherTeam.tied) return !true; else if (won*3 + tied > otherTeam.won*3 + otherTeam.tied) return !false; else { if (goalsshot-goalsreceived < otherTeam.goalsshot-otherTeam.goalsreceived) return !true; else if (goalsshot-goalsreceived > otherTeam.goalsshot-otherTeam.goalsreceived) return !false; else { if (goalsshot < otherTeam.goalsshot) return !true; else if (goalsshot> otherTeam.goalsshot) return !false; else { if (won < otherTeam.won) return !true; else if (won> otherTeam.won) return !false; else { return !(order teamList; struct matchResult { bool exists; int score1; int score2; }; int getPlaces(int n) { int result = 1; while (n>=10) { n /= 10; result++; } return result; } int main(void) { int teamCount; int maxlength=0; while ((cin>>teamCount) && (teamCount!=0)) { teamList.clear(); string dummy; getline(cin, dummy); for (int i=0;i maxlength) maxlength = teamName.length(); } matchResult** matchResults = new matchResult*[teamCount]; for (int i=0; i< teamCount; i++) { matchResults[i] = new matchResult[teamCount]; for (int j=0; j< teamCount; j++) matchResults[i][j].exists = false; } int matchCount = 0; cin >> matchCount; for (int i=0; i> team1Name; cin >> dummy; cin >> team2Name; cin >> team1Score; cin >> dummychar; cin >> team2Score; int team1Index; int team2Index; for (team1Index = 0; teamList[team1Index].name != team1Name; team1Index++); for (team2Index = 0; teamList[team2Index].name != team2Name; team2Index++); matchResults[team1Index][team2Index].exists = true; matchResults[team1Index][team2Index].score1 = team1Score; matchResults[team1Index][team2Index].score2 = team2Score; teamList[team1Index].goalsshot += team1Score; teamList[team1Index].goalsreceived += team2Score; teamList[team2Index].goalsshot += team2Score; teamList[team2Index].goalsreceived += team1Score; if (team1Score > team2Score) { teamList[team1Index].won++; teamList[team2Index].lost++; } else if (team1Score < team2Score) { teamList[team2Index].won++; teamList[team1Index].lost++; } else { teamList[team1Index].tied++; teamList[team2Index].tied++; } } string nameDashes = ""; for (int i=0; i< maxlength; i++) nameDashes += '-'; string teamDashes = ""; for (int i=0; i< teamCount; i++) teamDashes += "---+"; string dashes = "+" + nameDashes + "+" + teamDashes; cout << "RESULTS:" << endl << dashes << endl << "|" << setw(maxlength) << " " << "|"; for (int i=0; i maxPlayed) maxPlayed = teamList[i].won + teamList[i].lost + teamList[i].tied; if (teamList[i].won > maxWon) maxWon = teamList[i].won; if (teamList[i].lost > maxLost) maxLost = teamList[i].lost; if (teamList[i].tied > maxTied) maxTied = teamList[i].tied; if (teamList[i].won > maxWon) maxWon = teamList[i].won; if (teamList[i].won*3+teamList[i].tied > maxPoints) maxPoints = teamList[i].won*3+teamList[i].tied; if (getPlaces(teamList[i].goalsshot) + getPlaces(teamList[i].goalsreceived)+1 > maxGoalPlaces) maxGoalPlaces=getPlaces(teamList[i].goalsshot) + getPlaces(teamList[i].goalsreceived)+1; } for (int i=0; i