1
for(m = 0; m < voter_count; m++)
      {
for(t = 1; t < 4; t++)
{
string name = get_string("Rank %i: ", t);
}
printf("\n");
}

} bool vote(int voter, int rank, string name) { for (z = 0; z < candidate_count; z++) { if(strcmp(candidates[z].name, ) == 0) {

    }
}
return false;

}

2 Answers 2

1

To check the name of the candidate in the 1st preferred coloumn only

Remember,

preferences[i][j];

Is simply,

preferences[row][coloumn];

So, For first preference only

preferences[changing_row][1st_coloumn];

Inside this cell is just a number, Use it to match the name of the candidate.

1
  • thanks it helped Jul 16, 2020 at 20:27
1
vote

This function inputs a string a search for the names in the table of candidates, it returns true once the name has been founded or matched i.e == 0

But how?

Use for-loop to iterate through the candidate_count and check the name of the candidate by using strcmp declared in string.h

if (strcmp(candidate[i].names, name) == 0)
{
  return true;
}

In this way iterate through every Candidate and try to match the name if yes then return true else return false

1
  • but how do you single out rank 1 Jul 16, 2020 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .