Football Championship - V2 PDF
Document Details
Uploaded by IssueFreeUnity
Tags
Summary
This document contains C++ code for a football championship simulation. The code includes functions for initializing the score board, weekly standings, entering match results, and displaying the standings. The simulation is designed to track the performance and points of various teams throughout the championship.
Full Transcript
\#include \ \#include \ using namespace std; const int NB\_TEAMS = 5; const int SIZE = NB\_TEAMS + 1; // Function prototypes void initializeBoard(int SB\[\]\[SIZE\]); void initializeWeeklyStanding(int WS\[\]\[5\]); void enterResults(int SB\[\]\[SIZE\], int WS\[\]\[5\]); void showWeeklyLeagu...
\#include \ \#include \ using namespace std; const int NB\_TEAMS = 5; const int SIZE = NB\_TEAMS + 1; // Function prototypes void initializeBoard(int SB\[\]\[SIZE\]); void initializeWeeklyStanding(int WS\[\]\[5\]); void enterResults(int SB\[\]\[SIZE\], int WS\[\]\[5\]); void showWeeklyLeagueStanding(int WS\[\]\[5\]); void sortWeeklyLeagueStandingByPoints(int WS\[\]\[5\]); bool isChampionshipOver(const int SB\[\]\[SIZE\]); //void findWinners(const int WS\[\]\[5\]); int main() { int SB\[SIZE\]\[SIZE\]; // the Score Board int WS\[SIZE\]\[5\]; //Weekly standing info initializeBoard(SB); initializeWeeklyStanding(WS); while (!isChampionshipOver(SB)) { enterResults(SB, WS); showWeeklyLeagueStanding(WS); } //findWinners(WS); return 0; } // Function to initialize the Score Board with -1 void initializeBoard(int SB\[\]\[SIZE\]) { for (int i = 0; i \< SIZE; i++) { for (int j = 0; j \< SIZE; j++) { SB\[i\]\[j\] = -1; } } } void initializeWeeklyStanding(int WS\[\]\[5\]) { for (int i = 1; i \ guestg; } while (guestg\=10); if (homeg \> guestg) WS\[hometi\]\[2\] += 3; else if (homeg == guestg) { WS\[hometi\]\[2\] += 1; WS\[guestti\]\[2\] += 1; } else WS\[guestti\]\[2\] += 3; SB\[hometi\]\[guestti\] = homeg \* 10 + guestg; WS\[hometi\]\[3\] += homeg; WS\[hometi\]\[4\] += guestg; WS\[guestti\]\[3\] += guestg; WS\[guestti\]\[4\] += homeg; } } // Weekly display void showWeeklyLeagueStanding(int WS\[\]\[5\]) { sortWeeklyLeagueStandingByPoints(WS); int temp\[5\], tempo; for (int i = 1; i \