Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a)
- typedef struct
- {
- int clubID, dateSize;
- char venue[50 + 1], nameCoach[50 + 1], namePlayers[20][50 + 1];
- date_t dates[10];
- }club_t;
- b)
- typedef struct
- {
- date_t matchDate;
- club_t homeClub, awayClub;
- char venue[50 + 1];
- }match_t;
- c)
- /*
- * <summary> Determines if a club has conflicting dates with a match date </summary>
- * <params>
- * "club" = The club participating in the match
- * "date" = The date of the match
- * </params>
- * <return> "1": Has conflict - "0": No conflict </return>
- */
- int conflict(club_t club, date_t date)
- {
- int i;
- for(i = 0; i < club.dateSize; i++)
- if((club.dates[i].day == date.day) && (club.dates[i].month == date.month) && (club.dates[i].year == date.year))
- return 1;
- return 0;
- }
- d)
- /*
- * <summary> Determines the number of home games a club can play without conflicts </summary>
- * <params>
- * "tournament" = Contains the details of matches
- * "numMatches" = Contains the number of matches in the tournament
- * "club" = The club in the tourney
- * </params>
- * <return> The number of homegames </return>
- * <precond> "numMatches" > 0 </precond>
- */
- int numHomeGames(match_t tournament[],int numMatches, club_t club)
- {
- /*
- Matches to play AT HOME GROUND.
- Plays with every opponent once on homeground if possible.
- */
- int i, matchesToPlay = 0;
- /*
- *If it is the clubs match
- * Check for no conflicts
- */
- for(i = 0; i < numMatches; i++)
- if(tournament[i].homeClub.clubID == club.clubID)
- if(!conflict(club, tournament[i].matchDate))
- matchesToPlay++;
- return numHomeGames;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement