Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #define TRUE 1
- #define FALSE 0
- int main()
- {
- int n = 0; // Nímero de jugadors
- int m; // Màxim de jugadors
- srand(time(NULL));
- /** Obtindre els noms */
- printf("Numero de jugadors? ");
- scanf("%d",&m);
- char jugadors[m][20];
- for(int a=0; a<m; a++){
- printf("Jugador %d: ",a);
- scanf("%s",&jugadors[a]);
- }
- int historial[m];
- int repetit = FALSE;
- int x;
- for(int a=0; a<m; a++){
- do{
- x = rand() % m;
- repetit = FALSE;
- for(int b=0; b<a; b++){
- if(historial[b]==x) repetit = TRUE;
- }
- if(a==0) repetit = FALSE;
- } while ( repetit==TRUE );
- historial[a] = x;
- if(a%2==0) printf("\n");
- printf("%s\n",jugadors[x]);
- }
- system("sleep 10");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement