Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Smith
    @smith86n
    A PDF blog
    Hetparikh89
    @Hetparikh89
    Suppose that an engineer excitedly runs up to you and claims that they've implemented an algorithm that can sort n elements (e.g., numbers) in fewer than n steps. Give some thought as to why that's simply not possible and politely explain. someone can help me with this question?
    matrixbot
    @matrixbot
    . ¦3<RELATIVISM I dont see why that would not be possible Hetparikh89 (Gitter)
    . ¦3<RELATIVISM take for example the separation method
    . ¦3<RELATIVISM given some elements might already be in the right position
    . ¦3<RELATIVISM but yeah still learning though
    . ¦3<RELATIVISM .
    . ¦3<RELATIVISM .
    . ¦3<RELATIVISM o/ cs50x
    . ¦3<RELATIVISM I had a question
    . ¦3<RELATIVISM why in this simple script
    . ¦3<RELATIVISM my output seams to be tabed

    . ¦3<RELATIVISM "#include <stdio.h>

    int main(void)
    {
    int a = 3;
    int v;
    v = a;
    printf("v is %i\n", v);
    }"

    . ¦3<RELATIVISM output is:
    v is 3
    . ¦3<RELATIVISM and not:
    v is 3
    . ¦3<RELATIVISM ? any thoughs on that.
    . ¦3<RELATIVISM i tried again now and it doesnt seam to happend anymore strange, maybe was a bug I guess
    . ¦3<RELATIVISM .
    . ¦3<RELATIVISM .
    . ¦3<RELATIVISM also does anybody know with the free function
    . ¦3<RELATIVISM after the use of malloc that is,is there any argument to select all varibles that used allocation?
    AnishGhule-Technogeek
    @AnishGhule-Technogeek
    Can someone please help me find out what's wrong in my code for Credit. I am new to C programming

    include<stdio.h>

    include<cs50.h>

    int main(void)
    {
    int i, j, sum1, sum2, sum, card;
    i = 0;
    j = 0;
    sum1 = 0;
    sum2 = 0;
    sum = 0;
    long n, temp;
    n = get_long("Number: ");
    temp = n;
    while (n > 0)
    {
    i = n%10;
    n = n/100;
    / if (n/100 == 0)
    {
    card = n;
    }
    /
    sum1= sum1 + i;
    }

    i = 0;
    n = temp/10;
    
    while (n > 0)
    {
        i = n%10;
        n = n/100;
        i = i * 2;
        if (i/10 > 0)
        {
            j = i%10;
            i = i/10;
            i = i + j;
        }
        sum2 = sum2 + i;
    }
    
    sum = sum1 + sum2;
    
    if (sum%10 == 0 && n > (10^13))
    {
        /* if (card == 34 || card == 37)
        {
            printf("AMEX\n");
        }
        else if (card == 51 || card == 52 || card == 53 || card == 54 || card == 55)
        {
            printf("MASTERCARD\n");
        }
        else
        {
            printf("VISA\n");
        }
        */
    
        n = temp;
        if (n % (10^13) == 34 || n % (10^13) == 37)
        {
            printf("AMEX\n");
        }
        else if (n % (10^14) <= 55 && n % (10^14) >=51)
        {
            printf("MASTERCARD\n");
        }
        else if (n % (10^12) == 4 || n % (10^15) == 4)
        {
            printf("VISA\n");
        }
        else 
        {
            printf("INVALID\n");
        }
    }
    else
    {
        printf("INVALID\n");
    }

    }

    AnishGhule-Technogeek
    @AnishGhule-Technogeek
    ^^ Can someone please suggest edits. Thanks!
    matrixbot
    @matrixbot
    . ¦3<RELATIVISM AnishGhule-Technogeek (Gitter): would be better if you use apaste bin so people can more easilyreview your code
    . ¦3<RELATIVISM http://paste.debian.net/
    . ¦3<RELATIVISM as for you question sorry i cannot help you Imstill learning as well
    . ¦3<RELATIVISM have you tried using cs50 help lib?
    AnishGhule-Technogeek
    @AnishGhule-Technogeek
    @matrixbot paste.debian.net/ rejects to input the code. Can you please provide the link to cs50 help lib? I tried using help50, but it didn't help
    AnishGhule-Technogeek
    @AnishGhule-Technogeek
    @matrixbot Are you referring to https://manual.cs50.io/ ?
    matrixbot
    @matrixbot
    . ¦3<RELATIVISM why are thhe prerelease lectures double the time in 2020 comparing to 2019
    Nate M
    @WhipStreak23
    What do you mean? Is it possible just running over everything and later just refining the notes.
    khan786-dev
    @khan786-dev
    Hi every one...?
    how did i go about my hospital management system project . I have some confusion about my project .i don't know from where i start my project to go throughout the end.I need help and guidance
    bdpenski
    @bdpenski
    Dropping a, "Hello," as I am new to the course. I'm also very new to coding and computers in general, so any advice is welcome. Happy studying, everyone!
    RuweidoF
    @RuweidoF_twitter
    Hi everyone Can someone help me with projects 0 & 1 .....?
    matrixbot
    @matrixbot
    . ¦3<RELATIVISM RuweidoF (Gitter): what do you need help with? dont ask to ask and you get more responses
    Shishir Modi
    @ShishirModi
    Hey there! I needed help with submitting the projects
    No-Face23
    @No-Face23
    @ShishirModi yeah fire away
    beccklly115
    @beccklly115
    i need help to upload my project to pc
    Ghost
    @ghost~5f9dbc18d73408ce4ff2fed0
    How do I use the debugger in the IDE?
    Ghost
    @ghost~5f9dbc18d73408ce4ff2fed0
    i got it
    Ghost
    @ghost~5fa82577d73408ce4ff39080
    H
    Ikechukwu Godwin
    @Ikechuk89511135_twitter
    hello
    matrixbot
    @matrixbot
    . ¦3<RELATIVISM o/ Ikechukwu Godwin (Gitter)
    fuegopazzo
    @fuegopazzo

    Hi, I'm having issues with pset3 , Plurality and check50 . Hi, I cannot find any problem with my code. It seems to do everything that is supposed to do.
    Here's the code:

    // cs50 2020
    //PSET 3 Plurality
    // takes count of user defined number of
    //voters in election and returns result
    //

    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 votes;
    }
    candidate;

    // Array of candidates
    candidate candidates[MAX];

    // Number of candidates
    int candidate_count;

    // Function prototypes
    bool vote(string name);
    void print_winner(void);

    int main(int argc, string argv[])
    {
    // Check for invalid usage
    if (argc < 2)
    {
    printf("Usage: plurality [candidate ...]\n");
    return 1;
    }

    // Populate array of candidates
    candidate_count = argc - 1;
    //checks if candidate numberis above MAX
    if (candidate_count > MAX)
    {
        printf("Maximum number of candidates is %i\n", MAX);
        return 2;
    }
    //assigns location in array
    for (int i = 0; i < candidate_count; i++)
    {
        candidates[i].name = argv[i + 1];
        candidates[i].votes = 0;
    }
    
    int voter_count = get_int("Number of voters: ");
    
    // Loop over all voters
    for (int i = 0; i < voter_count; i++)
    {
        string name = get_string("Vote: ");
    
        // Check for invalid vote
        if (!vote(name))
        {
            printf("Invalid vote.\n");
    
        }
    }
    
    // Display winner of election
    print_winner();

    }

    // Update vote totals given a new vote
    bool vote(string name)
    {

    for(int i = 0; i < candidate_count; i++)
    {
        if (strcmp(name,candidates[i].name) == 0)
        {
          candidates[i].votes++;
    
    
          return true;
        }
    
    }
    return false;

    }

    // find and store highest vote total
    void print_winner(void)
    {
    int record = 0;
    for (int i = 0; i < candidate_count; i++)

    {
    if ( candidates[i].votes > record)
    {
    record = candidates[i].votes;
    }
    }
    //print winners

    //printf("The winner is/are: \n");

    for (int i = 0; i < candidate_count; i++)
    {
    if (candidates[i].votes == record)
    {
    printf("%s \n", candidates[i].name);

       }

    }
    return;
    }

    I get these errors from check50
    :( print_winner identifies Alice as winner of election
    print_winner function did not print winner of election
    :( print_winner identifies Bob as winner of election
    print_winner function did not print winner of election
    :( print_winner identifies Charlie as winner of election
    print_winner function did not print winner of election
    :( print_winner prints multiple winners in case of tie
    print_winner function did not print both winners of election
    :( print_winner prints all names when all candidates are tied
    print_winner function did not print all three winners of election

    Any help would be most appreciated

    matrixbot
    @matrixbot
    . ¦3<RELATIVISM fuegopazzo (Gitter): nextime usea pastebin is easier for people to check your code
    fuegopazzo
    @fuegopazzo
    Sorry, it's my first time
    matrixbot
    @matrixbot
    . ¦3<RELATIVISM no worries use maybe paste.debian.net
    . ¦3<RELATIVISM is a good, or bpa.st one or is also trusted