Any thoughts on that to set rank for all preferences?
-
i tried to update preferences by using preferences[ranks[i][i+1]; still giving the same error– Mannawar HussainJan 18, 2020 at 11:54
-
Please try to check the manual on how to post on this forum. it is very hard to read if you post a picture like that. try posting the code and a complete breakdown of your question.– ChrisJan 19, 2020 at 9:45
1 Answer
If you start adding notes to your code it will make it easer for others to understand.
So the basics of it are correct. You are iterating over all the candidates
Then there is an error, candidates[i] candidates is a data structure that is created at the begging of the code.
// Candidates have name, vote count, eliminated status
typedef struct
{
string name;
int votes;
bool eliminated;
}
candidate;
This means that if you want to call the name of candidate 1 you need to call candidates[0].name if you want to call his votes then you need to call candidates[0].votes etc.
Then to you actual question
How to set rank for all preferences?
Try rewatching the walkthrough a couple times.
preferences[MAX_VOTERS][MAX_CANDIDATES]
It preferences are marked as a double array that tracks the [voter] and the [rank].
The table in the walkthrough is a very good way to visualize what should be inscribed in the array.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)
-
Hi Chris! Noted, but this one is for tideman (bool vote function) Jan 19, 2020 at 11:05
-
Understood, I change your tag to reflect that. Sorry I could not be of more help– ChrisJan 19, 2020 at 11:08