Questions tagged [runoff]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
70 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
1answer
83 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
3answers
39 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
1answer
515 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
1answer
196 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
1answer
32 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
1answer
73 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
5answers
94 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
1answer
54 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
2answers
7k 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 ...
1
vote
1answer
72 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
5answers
124 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 ...
1
vote
1answer
841 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 ...
0
votes
1answer
487 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 ...
0
votes
2answers
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
2answers
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
1answer
7 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
1answer
7 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
1answer
12 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
1answer
15 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
1answer
29 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
1answer
50 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
1answer
78 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
2answers
96 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
1answer
57 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
1answer
174 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
1answer
100 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
1answer
41 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
1answer
129 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
1answer
147 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
1answer
227 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
1answer
1k 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
1answer
757 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
1answer
282 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
0answers
8 views

Tabulate function in Runoff

Here is my code void tabulate(void) { for (int i = 0; i < candidate_count; i++) if (strcmp(candidates[preferences[i][0]].name, candidates[i].name) == 0) { ...
0
votes
1answer
11 views

Vote Function in Runoff

Here's my code bool vote(int voter, int rank, string name) { int j = 0; for (int i = 0; i < voter_count; i++) if (strcmp(name, candidates[i].name) == 0) { preferences[i][...
0
votes
0answers
13 views

Is my vote function correct in Runoff?

I have started runoff and just completed step 1 that is to write the vote function can someone tell me if it's correct? It seems to give the correct output but I don't think I used int rank in the ...
0
votes
0answers
5 views

pset 3 runoff - problem with tabulate

I am a (very) beginner coder, so pls be gentle!! I have numerous mistakes in my code, but am unsure how to fix them. The code is working for some things, and I have scored 73 % on the problem set, but ...
0
votes
1answer
29 views

CS50 Runoff Tabulate

So I have been working on the tabulate function and Check50 says that the function is correct and it does properly work when no candidate is eliminated and when one is eliminated, but not when ...
0
votes
1answer
54 views

My runoff problem doesn't pass check50

when I run check50 this is the message I get and I don't know what to fix :( tabulate counts votes when all candidates remain in election tabulate function did not produce correct vote totals :( ...
0
votes
1answer
28 views

PSET3 Runoff specification (year 2020): Multiple eliminated candidates featuring in the next-preferred candidates list

In the pset3 Runoff specification (year 2020), every voter effectively votes for their top-preferred candidate who has not already been eliminated. If the top-preferred candidate has already been ...
0
votes
1answer
23 views

*** No rule to make target 'runoff'. Stop. Even though I'm in the correct directory

I keep getting the No rule to make target error on the runoff problem even when I'm in the correct directory as you can see in the picture attached. Note: I have just completed the vote function for ...
0
votes
1answer
24 views

CS50 Runoff – Cannot get program to execute, am I stuck in an infinite loop somewhere?

I'm trying to execute runoff but after I enter the voters' ranks, the terminal window blinks back at me with nothing. I've scoured all over for similar problems but cannot figure out a solution. I've ...
0
votes
1answer
47 views

Pset3 runoff tabulation error

[![enter image description here][1]][1] I keep getting a tabulation error with check50 that I cannot replicate 11 voters, 4 candidates, 3 or 4 rounds of voting works fine with I run it, and debug50 ...
0
votes
1answer
49 views

Trouble with find_min

I'm trying to implement a bubble sort in the find_min function in pset3 runoff. But It looks like it is not returning the correct min. I think it is because candidates[0].votes may not be the lowest ...
0
votes
0answers
51 views

Pset 3 runoff : I am getting{ :( runoff compiles code failed to compile}

I wrote my code but when I came to test it it gives me code failed to compile. I don't know why? :| here is my code #include <cs50.h> #include <stdio.h> #include <string.h> // Max ...
0
votes
1answer
60 views

Pset3 Runoff - Printing All Candidates

Could use some help with Runoff. If I do a simple clear winner (all voters vote for the same person as first choice) it prints out the winner just fine. But if I do the test input that the problem ...
0
votes
1answer
20 views

what does different return value signifies in this problem of runoff?

#include <cs50.h> #include <stdio.h> // Max voters and candidates #define MAX_VOTERS 100 #define MAX_CANDIDATES 9 // preferences[i][j] is jth preference for voter i int preferences[...
0
votes
1answer
57 views

pset3 runoff print_winner check50 error

So I have seen this issue mentioned here before and the others have suggested that printing a newline after the name is the solution. However, my code does print a newline and in my tests, I'm getting ...
0
votes
1answer
46 views

Back again with runoff problems, tabulate() passes no check50 tests

(I can't get formatting to work properly here so it might look a bit weird) void tabulate(void) { int j = 0; for(int i = 0; i < candidate_count; i++) { for( ; j < voter_count;) { ...