Questions tagged [plurality]
The plurality tag has no usage guidance.
21
questions with no upvoted or accepted answers
0
votes
1
answer
9
views
calling the first element in struct
I have defined an array of pairs of elements using struct and I'm trying to call (and sort) it using one of the elements (I'm not sure if element is the right term for it)
for example, I have
typedef ...
0
votes
0
answers
10
views
How to select a different result in the same integer
Hey I don't really know how to ask my question, I will try to summarize.
In candidates[i].votes I want to add a if to printf a specific things if I get two candidates the same results. In the base ...
0
votes
1
answer
25
views
It doesn't print Alice as the winner
when I try my code manually it does everything correct, but when I run Check 50, it says following ":( print_winner identifies Alice as winner of election print_winner function did not print ...
0
votes
0
answers
52
views
Week3 pset3 Plurality "print_winner function did not print all three winners of election"
Check50 passes all checks except for the very last one "print_winner function did not print all three winners of election"
:) plurality.c exists
:) plurality compiles
:) vote returns true ...
0
votes
1
answer
21
views
PSet3 Plurality - Segmentation Fault when exiting main
My code seems to function properly until I try to exit main. At this point it reports a segmentation fault. This only occurs when there is a tie.
Here is my code:
#include <stdio.h>
#include <...
0
votes
0
answers
213
views
Help on Plurality Pset3
I'm trying to solve assignment "Plurality" of Problem set 3. However, check50 didn't prove to be quite useful for me this time. I'm having only one error message saying "print_winner&...
0
votes
0
answers
81
views
CHECK50 for Plurality shows bug which manual testing can't find
Could anyone perhaps help me figure out what's wrong with the code below? When I check it manually, it works every time, in every scenario I can think of, but when I run check50 on it, I get ":( ...
0
votes
0
answers
52
views
Plurality works with my examples, but not with check50
I have finished my plurality program and its fine with the examples I give it, but it fails to print any of the winners of the Check50 examples. Any idea of how can I reproduce that elections, to see ...
0
votes
3
answers
74
views
Even though I get correct output check50 shows error in pset3 plurality problem
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max number of candidates
#define MAX 9
// Candidates have name and vote count
typedef struct
{
string name;
int ...
0
votes
1
answer
84
views
Pset3 Plurality returning "Invalid vote" in main programme code
When inputting vote names in "Plurality", the programme is returning Invalid vote. It looks like this in the terminal:
./plurality Alice Bob Garry Jim
Number of votes: 4
Vote: Alice
Invalid ...
0
votes
1
answer
63
views
Pset 3 Plurality Help (still not working)
When I compile my code it works, but when I try to run it, it says segmentation fault. I believe the segmentation fault is on the line that says printf("Winner is %s with %i votes\n", winner,...
0
votes
1
answer
22
views
Prints " Invalid vote " for " code 1 " as vote function But works fine for " code 2 " as vote function. Whats wrong with " code 1 "?
// CODE 1 :-
bool vote(string name)
{
// TODO
for (int i = 0; i < candidate_count; i++)
{
if ( candidates[i].name == name )
{
candidates[i].votes = candidates[i].votes + 1 ;
return true ;
}
}
...
0
votes
0
answers
44
views
Pset3 Plurality Help Again
This time I'm able to compile and run my code properly, but it tells me that there is a segmentation fault. Can someone help me figure out how to fix it? My code is below, thanks.
#include <stdio.h&...
0
votes
2
answers
309
views
PSET3 Plurality Problem
void print_winner(void)
{
// TODO
int c = 1;
int numwin = 1;
candidate mv[MAX];
mv[0].votes = -1;
for(int i = 0; i < candidate_count; i++)
{
if(candidates[i].votes >...
0
votes
2
answers
396
views
CS50 pset3 plurality program gives error for print_winner function (did not print both winners of election)
I have finished the plurality program for pset3 of cs50, but upon running check50 on my code, I receive the following error directed towards the print_winner function:
:) plurality.c exists
:) ...
0
votes
2
answers
150
views
Why am I running into a segmentation error in PSET 3 plurality?
I've been working on plurality for hours now and I'm stuck with a "segmentaion error." So my approach to this problem was to sort the candidate objects in terms of votes and print the first object (...
0
votes
0
answers
434
views
:( print_winner identifies Alice as winner of election. print_winner function did not print winner of election
What kind of test I should do to know What is the problem in my code because it's the only issue I have
every other condition is working good.
0
votes
1
answer
52
views
My Plurality.c works when I test it with all of their usage examples but when I run check or submit it says it doesn't print
I'm a beginner and CS50 is the first coding experience I have. Like the title says, my code works when I test it but the CS50 won't accept it so I'm not sure what's wrong. Thanks for any help!
ps. ...
0
votes
1
answer
202
views
pset3 I did print winner from pluarity, but check50 says I didn't. What's wrong?
I ran plurality according to spec and was able to print out all winners correctly. check50 says I didn't. What could be the problem? Is there any way to see what check50 used as inputs for plurality? ...
0
votes
2
answers
652
views
Error testing in plurality question
I already test my code with all possible input and it working fine but when I run with check50 cs50/problems/2020/x/plurality, I got a couple of error result
:( print_winner identifies Bob as ...
0
votes
1
answer
182
views
Plurality - check50 issue
Hoping for some insight on this.. code works perfectly fine, prints correctly when testing in terminal, but for some reason check50 outputs errors once it starts printing winners. Would love to find ...