lundi 19 décembre 2022

I have such a code and I don't want my random function to return the random numbers it previously gave,what can i do to fix this [duplicate]

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {  
    srand(time(NULL));
    int i = 0;
    int dizi[20];

    for (i = 0; i < 20; i++) {
        dizi[i] = rand() % 20;
    }   

    for (i = 0; i < 20; i++) {
        printf("%d\n", dizi[i]);
    }   
    
    return 0;
}

Is the if else structure sufficient to solve this problem or do I need to do something about the rand function?




Aucun commentaire:

Enregistrer un commentaire