Advertisement
Kyrexar

Emparejador

Mar 14th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream.h>
  2.  
  3. int main(){
  4.     int v[1000], i, j, aux, jugadores, grupos;
  5.     char nombres[100][100];
  6.     srand(time(NULL));
  7.    
  8.     cout << " Introduce cuantos jugadores: ";
  9.     cin >> jugadores;
  10.    
  11.     cout << " En grupos de: ";
  12.     cin >> grupos;
  13.    
  14.     for( i=0 ; i<jugadores ; i++ )
  15.          v[i]=i;
  16.          
  17.     for( i=0 ; i<jugadores ; i++ ){
  18.          j=(rand()%jugadores);
  19.          
  20.          aux=v[j];
  21.          v[j]=v[i];
  22.          v[i]=aux;
  23.     }cout << "\n" ;
  24.    
  25.     for( i=0 ; i<jugadores ; i++ ){
  26.          cout << " Introduce otro nombre: ";
  27.          cin >> nombres[i];
  28.     }cout << "\n " ;
  29.          
  30.     for( i=0 ; i<jugadores ; i++ ){
  31.          cout << nombres[v[i]] << "\n ";
  32.          if( (i+1)%grupos==0 ) cout << " --- \n ";
  33.     }cout << "\n " ;
  34.    
  35.     system("PAUSE");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement