In the last week, the head of the Australian Olympic Committee has expressed unease about the rate of progress being made for the Olympics Games in Rio De Janiero in 2016. As we all know, the most important part of the Olympics is the Medal Tally Table for the countries competing at the games. Our task is to supply a program, written in C, which will run as a backup in case the on-line systems fail. It will use simple text files for input so that it will not rely on any on-line information. For simplicity, each country will be known by its 3-character country code. The Medal Tally Table is a simple concept – each competing country is listed with its Gold, Silver, and Bronze Medals, and also its Total Medal count. However, it is also necessary to list those countries which have won medals in order of their levels of success.
The program is required by October 15, 2013 and must be thoroughly tested in pilot form by then. It will then be used at a Friendly Meet later in 2013, at which there will be just 25 countries (unlike the 200+ that will likely compete at the Olympics). You should make the change from 25 to over 200 an easy one to make.
The countries to complete at the Friendly are: AUS, BRA, BUL, CHN, COL, ETH, FRA, GBR, GER, HUN, ITA, JAM, KEN, MEX, NOR, POL, POR, RUS, SAF, SPA, TAN, USA, UZB, ZAM, ZIM. Argentina (ARG) has been specifically excluded to give Australia (AUS) a chance to be at the top of at least one medal tally table – the alphabetical one (sorry Pablo).
The one complicating factor with Olympic events (and many other sporting events) is that it is possible for athletes to tie (or dead-heat), and so it is possible for an event to have more than one medal awarded of a particular type. This is a very rare occurrence (except in some combative sports), and so we will assume that results like a triple dead-heat are not possible, but we will allow for an event to contain both a head-heat for first place followed by a dead-heat for third place. This means that as well as identifying countries winning medals for an event, we will need the top 4 finishers and their positions (because there may be up to 4 medallists). The result data for an event will therefore need 4 results, with the possible results being 1st, 2nd , 3rd, 4th (the normal case); 1st, 2nd, 3rd, 3rd (dead-heat for 3rd place); 1st, 2nd , 2nd, 4th (dead-heat for 2nd); 1st, 1st, 3rd, 3rd (dead-heat for both 1st and 3rd); and 1st, 1st, 3rd, 4th (dead-heat for 1st). Remember that only the competitors who place 1st, 2nd, or 3rd are awarded medals.
Your program will read two data files, set up in the same folder as was done for the first assignment. These data files are called input2a.dat and input2b.dat. You program should have the following steps:
Observation: While it is possible to complete this assignment using a number of parallel arrays, your design will be better and easier to work with (especially for sorting the results), if you define your own structured type (you should use our naming convention of structname_t), and then have a single array of these objects. Your design will also benefit from having a number of functions. A solution that does not have well designed functions to perform major tasks, will be marked down significantly.
Output should be produced along the following guidelines: Name should be right-justified as stated above, The medal counts are each integers and so an appropriate field size can be used to obtain proper column-style output. Use headings as appropriate to display the data as a table. E.g.
Medal Tally - Alphabetical Order
Country Gold Silver Bronze Total
---------------------------------------------
AUS 24 12 10 46
BRA 15 13 19 47
BUL 6 10 8 24
CHN 22 24 20 66
………… etc.
There will be 25 country names in the first (input2a.dat) data file. The countries you should use are listed above. We may run your program using a different list of countries, and if you are from overseas and I have not mentioned your particular country, you may leave out a country and insert your own, but you will have to alter the second data file to take account of this. While the file containing the country list will always have 25 country names, the second data file may have any number of complete data sets. Data for the results of a few events are listed below – you should add to this so that there is enough data to properly test the different aspects of your program (e.g.):
Mens-100m 1 JAM 2 USA 3 USA 4 AUS
Womens-100m 1 USA 2 JAM 3 USA 4 USA
MensLongJump 1 BUL 2 AUS 3 HUN 4 ITA
Pole-Vault 1 AUS 2 RUS 3 POL 4 HUN
Boxing57kg 1 ZAM 2 USA 3 SAF 3 ZIM
Mens5000m 1 KEN 2 ETH 3 KEM 4 BUL
Womens-200m 2 JAM 1 USA 3 AUS 4 POL
Note 1: The 57kg Boxing event shows the way that dead-heats are recorded
Note 2: that the second last data set contains an error which would be reported as
Error: Mens5000m Country KEM not competing
Note 3: The last data set is in error and would be reported as
Error: Womens-200m Results 2 JAM 1 USA 3 AUS 4 POL are invalid
It will be normal for these to be one set of data representing one event per line. As each event is run, extra data can then be easily added to the end of the input2b.dat file.