Random function exclusive and without repetition - Language C

0

Well, I'm doing a C language program, and I need to do some raffles, but they can not be repeated, the program does the input control of a lecture, and will have a draw, in that draw can not be drawn the same numbers, I'm doing lottery by row and chair. simulating 30 rows and 60 chairs in each row, I even managed to make the draw, but I'm not getting the reps. Here's the code I did, but it did not work:

void sorteio(int cadeiras[30][60], dados cadastro[3]){

    int a,b,c,d,f[30],p[60],i=0;

    do{
        cadeiras[c=(rand() % 29)][d=(rand() % 59)];
        for (a=0; a>29; a++){
            if(f[a]!=c){
                for (b=0; b>59; b++){
                    if(p[b]!=d){
                        if(cadeiras[c][d]==1){
                            f[i]=c;
                            p[i]=d;
                            i++;
                            printf("\n %d Os sorteado foram: %d fileira %d cadeira", i,c,d);
                        }
                    }
                }
            }
            else{
                for (b=0; b>59; b++){
                    if(p[b]!=d){
                        if(cadeiras[c][d]==1){
                            f[i]=c;
                            p[i]=d;
                            i++;
                            printf("\n %d Os sorteado foram: %d fileira %d cadeira", i,c,d);
                        }
                    }
                }
            }
        }
        //if()
        //if(cadeiras[c][d]==1){
          //  i++;
          //  printf("\n %d Os sorteado foram: %d fileira %d cadeira", i,c,d);
       // }
    }while(i!=15);
}
    
asked by anonymous 25.11.2018 / 19:23

0 answers