I'm working with an Eurovision Voting Contest Simulator.
26 countries have to randomly vote other 10 countries (without duplicates nor itself).
So I do a for (Countries.Length) and inside a for (PossibleVotes.Length) For assigning the votes.
Even handling a counter for highest voted (12points) to show 'TheBest' winners.
This is already done.
The code:
//struct array country[26]
//country[].sName = Spain, Italy, France...
//country.iVotes = Total votes
//country.iTwelves = Counter for total12 recieved
//country.iZeros = Counter for total 0 recieved
// iPossibleVotes[10] {12 , 10 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 }
for (int i = 0 ; i < country.Length ; i++){
Console.WriteLine("\n___Country " + (i+1) + " " + country[i].sName + "___");
Console.WriteLine("\nVotes:");
int[] iVotedCountry = Utils.RandomArrayWitoutDuplicates(i);
//Function to make an array of 10 random integers without duplicates nor itself (i value)
//Executes 10 times
for (int j = 0 ; j < iVotedCountry.Length ; j++){
Console.WriteLine("-" + country[iVotedCountry[j]].sName + " with " + iPossibleVotes[j] + " points. ");
//If j = 0 equals to iPossibleVotes[] =12, sum iTwelves counter
if (j == 0){
country[iVotedCountry[j]].iTwelves++;
}
} // END FOR (iVotedCountry.Length) Countries that are being voted.
for (int k = 0 ; k < country.Length ; k++){
if (k != iVotedCountry[j]) {
country[k].iZeros++;
}
}
} //END COUNTRY.Length ARRAY
//Expected output
Console.WriteLine("___TheLooser___\nThe country or countries with more zeros recieved are: " );
//Then sort them in an array
//BUT I can't handle to count the times a country hasn't been voted or voted '0'
Teacher asks to show also, the 'TheLooser' winner, which is the country (or the countries, in a tie) who have been less voted or voted '0'.
My idea is to assign '0' vote to the 16 other countries after I have assigned the real PossibleVotes to the 10 random countries.
Im also interested in pseudo-code abstract ideas or comments to think about it.
Thank you