daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Estudiante: Argenes Montoya Aguilar
  2. //Curso: Estructuras de datos
  3. // # de carnet: 201106385
  4. #include <cstdlib>
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. void Permutaciones(char * s, int k) {
  9.    char x;    
  10.    int h, z;  
  11.    int n = strlen(s);
  12.  
  13.    for(h = 0; h < n-k; h++) {
  14.       if(n-k > 2) Permutaciones(s, k+1);
  15.       else cout << s << "\n";
  16.      
  17.       x = s[k];
  18.       s[k] = s[k+h+1];
  19.       s[k+h+1] = x;
  20.       if(k+h == n-1) {
  21.          for(z = k; z < n; z++) s[z] = s[z+1];
  22.          s[n] = 0;
  23.       }
  24.    }
  25. }
  26.  
  27.  
  28. void Permutaciones(char *, int k=0);
  29.  
  30. int main(int argc, char *argv[]) {
  31.    char palabra[] = "WORD";
  32.    Permutaciones(palabra);
  33.    
  34.    cin.get();
  35.    return 0;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top