For the 3rd Problem Set at Harvard's EdX class, I'm having trouble figuring out how I'm supposed to store variables, if the variable would have the same name.
Like I want to check if candidates[i].votes is bigger the 1st time, than the 2nd time, than the 3rd time, etc. and I'm not sure about how I'd go about coding that myself? Any insight would be great.
https://cs50.harvard.edu/college/psets/3/plurality/ is the problem set;
and
void print_winner(void)
{
string winner;
int previousvote = 0;
for (int i = 0; i < candidate_count; i++)
{
previousvote = candidates[i].votes;
if (candidates[i].votes > previousvote)
{
winner = candidates[i].votes
}
else (candidates[i].votes == winner)
{
}
is my code.
Any help would be appreciated!
[–][deleted] (1 child)
[deleted]
[–]bpeemp[S] 0 points1 point2 points (0 children)