Im coding a project in C and Im trying to create a matrix with random numbers from 1 to 52 not repeated but keeps repeat always 1 number!
void baralhar(int b[]){
int x,y,r;
for(x=0;x<53;x++){
r=rand() % 52+1;
for(y=0;y<=x;y++){
if(r==b[y])
{
y=0;
r=rand() % 52+1;
}
}
b[x]=r;
}
}
Output: 49 2 3 23 15 50 29 12 33 37 6 21 9 16 14 38 41 31 36 10 39 43 40 30 48 7 4 8 5 18 34 46 1 47 27 13 51 42 17 19 25 20 26 35 28 52 49 45 24 32 22 44
in this example you can see the number 49 is repeat. Can you help here?