// Query for votes for (int i = 0; i < voter_count; i++) { // ranks[i] is voter's ith preference int ranks[candidate_count];
// Query for each rank
for (int j = 0; j < candidate_count; j++)
{
string name = get_string("Rank %i: ", j + 1);
if (!vote(j, name, ranks[j]))
{
printf("Invalid vote.\n");
return 3;
}
else
{
ranks[j] = save;
//Record_preferences should start here.
for(int k = 0; k < candidate_count; k++)
{
int c = j;
if(ranks[j] == k)
{
continue;
}
if(j > 0)
{
while(c > 0)
{
if(k == ranks[c-1])
{
--c;
goto next;
}
--c;
}
++preferences[ranks[j]][k];
next:
continue;
}
else
{
++preferences[ranks[j]][k];
}
}
//I commented out the record_preferences() function.
//record_preferences();
}
}
printf("\n");
}
add_pairs();
sort_pairs();
lock_pairs();
print_winner();
return 0;
}