Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define NUM 6
- int main(){
- int i,j,k,r,used;
- int v[NUM];
- char people[][200]={"Fulando","Beltrano","Ciclano","Xuxa","Sacha","Papa"};
- /*Repete a bagaça toda*/
- for(k=0;k<3;k++){
- /* Gera a permutacao aleatoria: */
- srand(time(NULL));
- for(i=0;i<NUM;i++){
- do{
- r=rand()%NUM;
- used = 0;
- for(j=0;j<i;j++)
- if (r==v[j])
- used=1;
- }while(used);
- v[i]=r;
- }
- /*Quem pergunta pra quem :*/
- printf("Sorteio %d:\n",k);
- for (i=0;i<NUM;i++)
- printf("%20s pergunta pra %-20s\n",people[v[i]],people[v[(i+1)%NUM]]);
- printf("\n\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment