fork download
  1. // Add supporting structures - expect many structure types
  2. // here ...
  3.  
  4. #define TRACK_NAME_LEN 50
  5. #define HORSE_NAME_LEN 50
  6. #define PERSON_NAME_LEN 50
  7. #define COLOR_LEN 20
  8. #define TRACK_CODE_LEN 10
  9. #define NOTES_LEN 128
  10. #define MAX_PAST_RACES 20
  11.  
  12.  
  13. // Stores a calendar date
  14. struct date
  15. {
  16. int mouth;
  17. int day;
  18. int year;
  19. };
  20.  
  21.  
  22. // TODO - add other supporting structures that could be
  23. // used as types for members of the two main structures below
  24.  
  25.  
  26. // Stores the time a race is scheduled to start
  27. struct time_of_day
  28. {
  29. int hour;
  30. int minute;
  31. };
  32.  
  33.  
  34. // Indicates the type of track surface
  35. enum track_surface
  36. {
  37. SURFACE_DIRT,
  38. SURFACE_TURF,
  39. SURFACE_SYNTHETIC,
  40. SURFACE_UNKNOWN
  41. };
  42.  
  43.  
  44. // Indicates the condition of the track
  45. enum track_condition
  46. {
  47. COND_FAST,
  48. COND_GOOD,
  49. COND_SLOPPY,
  50. COND_MUDDY,
  51. COND_FIRM,
  52. COND_YIELDING,
  53. COND_UNKNOWN
  54. };
  55.  
  56.  
  57. // Identifies the unit used for race distance
  58. enum distance_unit
  59. {
  60. DIST_FURLONGS,
  61. DIST_MILES
  62. };
  63.  
  64.  
  65. // Holds the actual distance value
  66. union distance_value
  67. {
  68. float furlongs;
  69. float miles;
  70. };
  71.  
  72.  
  73. // Combines distance unit and value
  74. struct distance
  75. {
  76. enum distance_unit unit;
  77. union distance_value value;
  78. };
  79.  
  80.  
  81. // Stores basic performance statistics
  82. struct performance_stats
  83. {
  84. int starts;
  85. int wins;
  86. int places;
  87. int shows;
  88. float earnings;
  89. };
  90.  
  91.  
  92. // Stores owner information
  93. struct owner_info
  94. {
  95. char name[PERSON_NAME_LEN];
  96. };
  97.  
  98.  
  99. // Stores trainer information and stats
  100. struct trainer_info
  101. {
  102. char name[PERSON_NAME_LEN];
  103. struct performance_stats stats;
  104. };
  105.  
  106.  
  107. // Stores jockey information and stats
  108. struct jockey_info
  109. {
  110. char name[PERSON_NAME_LEN];
  111. struct performance_stats stats;
  112. };
  113.  
  114.  
  115. // Stores information about one previous race for a horse
  116. struct past_performance
  117. {
  118. struct date raceDate;
  119. char trackCode[TRACK_CODE_LEN];
  120. int raceNumber;
  121. struct distance raceDistance;
  122. enum track_surface surface;
  123. enum track_condition condition;
  124. int fieldSize;
  125. int postPosition;
  126. int finishPosition;
  127. float lengthsBehind;
  128. float finalOdds;
  129. float finalTime;
  130. char comment[NOTES_LEN];
  131. };
  132.  
  133.  
  134. // add a structure to store details on each race
  135.  
  136. struct race_details
  137. {
  138. struct date raceDate; // A - the date of the race
  139. int raceNumber; // C - the specific race number identifier
  140. char trackName[50]; // E - the name of the track where the race was held
  141.  
  142. // TODO - add other members
  143. struct time_of_day postTime;
  144. enum track_surface surface;
  145. enum track_condition condition;
  146. struct distance raceDistance;
  147. float purse;
  148. char raceType[30];
  149. char raceNotes[NOTES_LEN];
  150. };
  151.  
  152.  
  153.  
  154.  
  155. // add a structure to store details on each horse
  156.  
  157. struct horse_details_and_past_performance
  158. {
  159. int programNumber; // 1 - the program number
  160. char horseName[50]; // 8 - horse name
  161. char horseGender; // 10 - gender of the horse
  162.  
  163. // TODO - add other members
  164. int age;
  165. char color[COLOR_LEN];
  166. struct owner_info owner;
  167. struct trainer_info trainer;
  168. struct jockey_info jockey;
  169. float todayWeightCarried;
  170.  
  171. struct performance_stats lifetimeStats;
  172. struct performance_stats trackStats;
  173. struct performance_stats surfaceStats;
  174.  
  175. int medicationFlags;
  176. int equipmentFlags;
  177.  
  178. struct past_performance pastRaces[MAX_PAST_RACES];
  179. int pastRaceCount;
  180. };
  181.  
  182.  
  183. int main()
  184. {
  185. // NOTE: You don't have to populate any of these!!!
  186.  
  187. struct race_details myRaces[10];
  188. struct horse_details_and_past_performance myHorses[20];
  189.  
  190. // nothing else needs to be added to main
  191. return 0;
  192. }
  193.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty