samedi 16 avril 2016

Can I return a different sequences from a function?

// I wrote a function that returns an array's values. The values must be chosen randomly. But in main function, when I call the funtion,it gives me the same values. I wanna different randomly numbers, Can I avoid it?

void a();

int main(){
a();
a();
return 0;
} 
void a(){
int i, b[6];
srand(time(NULL));

for(i=0; i<6; i++){
    b[i]= rand()%10 +1;
    printf("%d " , b[i]);
    if(i==5) printf("\n");
}
}




Aucun commentaire:

Enregistrer un commentaire