I've tried two different variations of my implementation of the find_min
functions and both times two of the requirements on check50
are achieved and only one shows an error.
Sucesses:
:) find_min returns minimum number of votes for candidate
:) find_min returns minimum when all candidates are tied
Error:
:( find_min ignores eliminated candidates
find_min did not identify correct minimum
Here's two variations of my find_min
function:
(Thanks for your time and help in advance :))
// variation 1
int find_min(void)
{
int min = voter_count;
for (int i = 0; i < candidate_count; i++)
{
if (candidates[i].eliminated == false)
{
min = candidates[i].votes;
for (int j = 0; j < candidate_count; j++)
{
if (candidates[j].votes <= min)
{
min = candidates[j].votes;
}
}
}
}
return min;
}
// Variation 2
int find_min(void)
{
int min = voter_count;
for (int i = 0; i < candidate_count; i++)
{
min = candidates[i].votes;
if (candidates[i].eliminated == false)
{
if (candidates[i].votes <= min)
{
min = candidates[i].votes;
}
}
}
return min;
}