Questions tagged [runoff]
The runoff tag has no usage guidance.
89
questions
2
votes
2
answers
2k
views
pset3 (runoff) keep getting print_winner error when using check50
I keep getting these errors when running check50 on my runoff program:
print_winner prints name when someone has a majority
print_winner did not print winner of election
print_winner returns ...
2
votes
2
answers
116
views
Trouble with vote function
I can't get the vote function in Runoff to work properly. Can anyone help explain what I am doing wrong here?
bool vote(int voter, int rank, string name)
{
for (int i = 0; i < voter_count; i++)
...
2
votes
4
answers
11k
views
cs50 pset3 runoff tabulate
i have completed the problem set however when i check,
this is the only problem.
:) tabulate counts votes when all candidates remain in election
:) tabulate counts votes when one candidate is ...
2
votes
1
answer
182
views
pset3 print_winner (prints name when someone has a majority)
I tried in two ways to show the winner of the election, and both testing manually are giving the correct result, but when testing by "check50" the message always appears:
:( print_winner prints name ...
1
vote
1
answer
1k
views
Pset3 Runoff - How to record name and rank in the Preferences Array?
Hi if anyone can guide me in the right direction to record name & rank in the preferences array?
I don't have any clue how to even utilize the int vote and int rank in the bool parentheses of the ...
1
vote
3
answers
114
views
PSET3 Runoff Help Please
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)
{
...
1
vote
2
answers
93
views
(!vote) in runoff [pset3]
I am having real difficulty understanding how calling the vote function for valid votes in runoff is supposed to work.
The relevant part of the distribution code is as follows:
// Record vote, unless ...
1
vote
1
answer
884
views
tabulate doesn't count votes when multiple candidates are eliminated
for (int i = 0; i < voter_count; i++)
{
// vote for top-preferred candidate if possible
if (candidates[preferences[i][0]].eliminated == false)
{
candidates[preferences[i][0]]....
1
vote
1
answer
225
views
Pset3 Runoff bool function
I don't understand what the parenthesis after bool vote function is for.
bool vote(int voter, int rank, string name)
It could have been (void), what purpose does it serve here?
Please make my ...
1
vote
1
answer
43
views
pset 3 runoff help again
I still dont know what to put in for loop :(
I still dont know what to put in the for loop
for(int k = 0; k < voter_count; k++)
{
for (int j = 0; j < candidate_count; j++)
{
...
1
vote
1
answer
220
views
runoff tabulate error :( tabulate counts votes when multiple candidates are eliminated
void tabulate(void)
{
for (int i = 0; i < voter_count; i++) //as long as the number of total voters has not been met; this increases which voter we are on
{
int j = 0;
...
1
vote
5
answers
153
views
Trouble with tabulate and printwinner
I'm having a hard time with the runoff problem in pset3, especially with the tabulate function. Based on the instructions it looks like I need to update the preferences array but I'm not sure how. I'm ...
1
vote
1
answer
68
views
Pset 3 Min function need some help
So my min code works, except it ignores the eliminate function. Can someone please show me where my logic is wrong? Thanks.
int find_min(void)
{
int min = voter_count;
int h = 0;
for (int i = 0; i ...
1
vote
1
answer
260
views
pset3 runoff help -> 3 :( showing on check50
I'm getting the following fails when I check pset3 runoff (all the rest are coming up as correct)
:( tabulate counts votes when multiple candidates are eliminated
tabulate function did not produce ...
1
vote
4
answers
203
views
check50 errors - runoff
I've been trying to resolve these myself for too long - I'm officially stuck
These are the check50 errors I get:
:( tabulate counts votes when multiple candidates are eliminated
:( find_min ignores ...
0
votes
1
answer
231
views
Pset3 - runoff - print_winner and find_min error
After I checked my code using check50 cs50/problems/2021/x/runoff, I received the following error messages for my bool print_winner(void) function and int find_min(void) function as follows
:( ...
0
votes
1
answer
2k
views
PSET 3 Runoff Error: variable length array declaration not allowed at file scope
I realize that this code is not well designed, however I will try to solve that once my code can compile.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
typedef struct
{
...
0
votes
2
answers
2k
views
PSET3 runoff 2020
I have some trouble with PSET3 2020 runoff:
in Specification:
Complete the implementation of runoff.c in such a way that it simulates a runoff election. You should complete the implementations of ...
0
votes
2
answers
207
views
PSET3 Runoff Vote Function
I'm having trouble understanding how to write this vote function. I understand what I wrote is incorrect because I am assigning a struct to an array of ints but I can't understand how I'm supposed to ...
0
votes
2
answers
72
views
Check50 all green but my own tests fail
I completed Runoff with 100% pass in check50 but when i do my own tests i get wrong winners. I checked everything to the best of my abilities but i just can't find the problem and it's driving me ...
0
votes
2
answers
2k
views
RUNOFF PSET3 - bool is_tie(int min) function gives an error in Check50 unable to remove
I have tried a number of ways to execute the code in bool is_tie function; however, I always seem to receive the same error in check50.
I have run the code through debug50 and it seems to work ...
0
votes
1
answer
191
views
PSET 3 runoff is_tie function
New to this platform, forgive me if there are some norm or etiquette I may be missing. Please feel free to provide feedback on anything that is incorrect.
This is for the is-tie function alone. I ...
0
votes
1
answer
71
views
pset3 runoff tabulate function not knowing where to start
Is it required to eliminate candidates within the tabulate function? How should we recognize when a candidate is eliminated and how do we go about increasing vote count catering for eliminated ...
0
votes
2
answers
46
views
Pset3 Runoff CS50x
I have been trying to debugg the program for a while but am not able to figure out what the error in line 9 is as this was the code provided by the courses and I didn't make any changes.
Any help ...
0
votes
1
answer
35
views
Vote indexing problem
my code works well in indexing all votes in the preferences except for the first one, I tried debugging and it worked well for all indexes including the first one..!
0
votes
1
answer
232
views
CS50 - pset3 - Runoff | Check50 failing print_winner on majority but works correctly for any manual test I can think of
I'm having trouble with getting Runoff to complete Check50. All checks are passing except the two below for the print_winner function
:( print_winner prints name when someone has a majority
Cause
...
0
votes
1
answer
975
views
Pset3 Runoff is_tie
Having issues with Check 50 and the is_tie function:
:( is_tie returns false when only some of the candidates are tied
is_tie did not return false
:( is_tie detects tie after some candidates have ...
0
votes
2
answers
398
views
Runoff Help: Tabulate Handles Multiple Rounds of Preferences
I cannot figure out why I am getting rejected on check50 for ":( tabulate handles multiple rounds of preferences - tabulate function did not produce correct vote totals". I get green ...
0
votes
1
answer
30
views
Tabulate not working when more than 1 candidate is eliminated
Here is my Tabulate Function -
void tabulate(void)
{
int j = 0;
for (int i = 0; i < voter_count; i++)
{
if (candidates[preferences[i][j]].eliminated == 1)
{
...
0
votes
1
answer
41
views
Please help me by reviewing my logic for Tabulate in Runoff Pset3
Let's say 3 candidates were their initially and A and B got 2 votes each while C got 1 hence C should be eliminated then in the next round we need to see the second preference votes right? As the ...
0
votes
1
answer
67
views
pset 3 Runoff Where is my code wrong?
I have written the functions but I am not sure which one is wrong as I am not getting any output
Here is my code:
// Record preference if vote is valid
bool vote(int voter, int rank, string name)
{
...
0
votes
1
answer
98
views
Tabulate in Runoff
Finally took a break for a few days to think about stuff and I am back at doing psets
Now I am trying to fix the tabulate function, here's my code -
void tabulate(void)
{
for (int i = 0; i < ...
0
votes
1
answer
357
views
Pset3 Runoff Find Min not Coded Properly - Can't Find Error
The way I have coded it, I believe my min should be set correctly, but when I try to run it, the check50 says it's wrong. I tested it by printing my min at various points in the code, and it is not ...
0
votes
1
answer
126
views
Pset 3 runoff. Votes not updating, trying to understand the code sequencing
Ok so im stuck on the tabulate funtion in runoff for pset3.
The issue im having is that when i call to "printf" the candidates vote counts the votes still come out as 0. So i dont think the ...
0
votes
2
answers
256
views
Pset3 Runoff tabulation issues
I am so close to a successful runoff program, but I've been having issues with the tabulation section. I decided that this was a good place to implement a recursive function, but it is a new concept ...
0
votes
1
answer
127
views
pset 3 runoff find_min - where is my logic failing ? - the check gives and error saying it doesn`t find the correct min
int find_min(void)
{
int min = voter_count;
for (int i = 0; i < candidate_count; i++)
{
if (candidates[i].eliminated == false && candidates[i].votes < min)
{
min = ...
0
votes
1
answer
356
views
Printing to stdout? (PSET3, RUNOFF)
In the specification for the print_winner function it says:
If any candidate has more than half of the vote, their name should be printed to stdout and the function should return true.
My solution ...
0
votes
1
answer
467
views
PSET3 Runoff - tabulate() function for multiple eliminated candidates
I'm working on the tabulate() function, and to an extent the is_tie() function
The tabulate() function passes all the tests of check50 but the last one:
:( tabulate counts votes when multiple ...
0
votes
1
answer
151
views
PSET3 Runoff check50 help
My code can compile and passes all the check50 except for this 2:
1) :( print_winner prints name when someone has a majority
print_winner did not print winner of election
2) :( print_winner ...
0
votes
1
answer
47
views
Vote returns false no matters what
bool vote(int voter, int rank, string name)
{
for(int n = 0; n == candidate_count - 1; n++)
{
if(strcmp(name, candidates[n].name) == 0)
{
n = preferences[voter][...
0
votes
1
answer
1k
views
pset3 Runoff help
My code compiles but the only functions that had no errors are the print_winner and eliminate functions. I have tried to solve the errors for the other functions with no luck.
My errors with the ...
0
votes
2
answers
232
views
what is the significance of break; in tabulate function?
I know break statements are pretty basic, but it's got me here:
This is my function:
for (int i = 0; i < voter_count; i++)
{
for (int j = 0; j < candidate_count; j++)
{
if (...
0
votes
1
answer
186
views
i can't get the vote function in runoff right
Here's the function i wrote:
bool vote(int voter, int rank, string name)
{
int t = 0;
int a = 0;
for (int i = 0; i < candidate_count; i++)
{
int x = strcmp(candidates[i]....
0
votes
1
answer
257
views
pset 3: 2 problems in runoff pointed by check50
My functions codes git link
Here are my errors and my function codes in a git link (thanks folks for the feedbacks). I just don´t get what´s going on here, maybe i´m missing a detail, but it does ...
0
votes
1
answer
2k
views
PSET3 Runoff - Tabulate
my tabulate function is storing votes from the preferences array, but problem arising when multiple candidates are eliminated check50 shows error there.
Please help me with this, and tell me what is ...
0
votes
1
answer
948
views
Why does runoff not stop running?
So when I run my code it does not stop running
~/pset3/runoff/ $ ./runoff mike john Number of voters: 3
Rank 1: john
Rank 2: mike
Rank 1: john Rank 2: mike
Rank 1: mike Rank 2: ...
0
votes
1
answer
313
views
vote function not able to assign getting error in runoff
[
Hi, i would like to set preference table but not able to set particular candidates evry time i am trying to change and set this i am getting different error. Any thought on this.
0
votes
0
answers
15
views
Hi guy!! Could you please help me with CS50 week 3 runoff on tabulate function?
here is my code
void tabulate(void)
{
// TODO
for (int i = 0; i < voter_count; i++)
{
for (int j = 0; j < candidate_count; j++)
{
for (int k = 0; k < candidate_count; k++)
...
0
votes
0
answers
18
views
I don't know why my code doesn't work correctly, can you help me? PSet03 - Runoff
I,ve been completed all the functions that i'd need to complete in the Pset Runoff but I don't know why when I do the check50 it gave some errors and My code doesn't print out the winner as well. Here ...
0
votes
0
answers
17
views
Runoff Problem Winner Fail to check
void tabulate(void)
{
// TODO
int n = voter_count;
int c = candidate_count;
// First votes
for (int i = 0; i < n; i++)
for (int j = 0; j < c; j++)
{
...