Skip to content

Random score generation in Ranking game #5

@QBatista

Description

@QBatista

In your C code for ranking games, the create_rand_score function does not use the start argument and relies on s[-1] (i.e. the element located before s in memory), which (I think) can potentially cause an error. Was this intended or did you mean something such as:

int *create_rand_score(int k, int steps)
{
    int i;
    int *s = malloc(k * sizeof(int));
    
    s[0] = 0
    for (i = 1; i < k; ++i)
        s[i] = s[i-1] + ((randint(steps) ) + 1);
    
    return s;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions