2

The problem is in this loop: for (int j = 1; j < candidate_count; j++) { if (candidates[preferences[i][j]].eliminated == false) { candidates[preferences[i][j]].votes += 1; } } If your preference 0 is taken it registers all other preferences. That is to say if their are 3 candidates and preference 0 has been eliminated it will add the ...


1

One problem I see: In tabulate() for(int i = 0; i > voter_count; i++) I think you meant to write i < voter_count because otherwise it will not enter the loop since your condition will turn out to be 0 > 2 The same holds true for the next loop as well: for (int j = 0; j > candidate_count; j++). Here too, change j > candidate_count to j < ...


Only top voted, non community-wiki answers of a minimum length are eligible