Ver Mensaje Individual
  #2 (permalink)  
Antiguo 31/01/2015, 07:36
amchacon
 
Fecha de Ingreso: julio-2012
Mensajes: 375
Antigüedad: 11 años, 9 meses
Puntos: 28
Respuesta: Permutaciones

Solucionado:
Código C++:
Ver original
  1. void permutaciones(int N,int arr[],int j = 0)
  2. {
  3.     if (j == N)
  4.     {
  5.         cout<<arr[0];
  6.         for (int i = 1; i<N; i++)
  7.         {
  8.             cout<<','<<arr[i];
  9.         }
  10.         cout<<endl;
  11.     }
  12.     else
  13.     {
  14.         bool posible;
  15.         for (int i = 0;i<N;i++)
  16.         {
  17.             posible = true;
  18.             for (int k = 0;k<j;k++)
  19.             {
  20.                 if (arr[k] == i) posible = false;
  21.             }
  22.             if (posible)
  23.             {
  24.                 arr[j] = i;
  25.                 permutaciones(N,arr,j+1);
  26.             }
  27.         }
  28.     }
  29. }