I was required to write a program that generate random results of 10 sport games where 10 countries are involved, and display the medal tally based on the results.
I was able to generate the games' result but have no idea how to sum up the results (i.e. the number of different medals earned by each country).
Below is part of my code to generate random game result.
const string ctry[] = {'A','B','C','D','E','F','G','H','I','J'}; //country name
int main()
{
string gctry[10]; //gold
string sctry[10]; //silver
string bctry[10]; //bronze
for (int i = 0; i < 10; i++)
{
gctry[i] = country[(rand() + time(0))%10];
sctry[i] = country[(rand() + time(0))%10];
bctry[i] = country[(rand() + time(0))%10];
}
}
I need some advice to solve this. Thanks.