Home > Programacion I > Codigo Posibles Combinaciones

Codigo Posibles Combinaciones

/* Este codigo se encuentra en lenguaje C */

#include <stdio.h>
#include <stdlib.h>

/* Funcion que da valores al arreglo del 1 hasta el numero de letras que se hayan ingresado */

int valor(int * p, int N)
{ int i;

for(i = 0; i < N; i++)
{ p[i] = i+1; }

return 1; }

/* — o — o — o — o — o — o — o — o — o — o — o — o */

/* Saca el factorial de un numero */

int factorial(int N)
{ int i, f;
f = 1;

for(i = 2; i < N+1; i++)
{ f = f * i; }

return f; }

/* — o — o — o — o — o — o — o — o — o — o — o — o */

/* Funcion que busca el factorial de un arreglo */

int multi(int * p, int N)
{ int i, m;
m =1;

for(i = 0; i < N; i++)
{ m = m * p[i]; }

return m; }

/* — o — o — o — o — o — o — o — o — o — o — o — o */

int main(int argc, char *argv[])
{
if(argc == 1)
{printf(“\n Escriba una palabra \n”);
return 0; }

int c = 0;
int s = strlen(argv[1]);
int i, k;

int * X;
X = (int*) calloc (s,sizeof(int));

valor(X, s);

printf(“\n”);

while(c < factorial(s))
{ if(multi(X,s) == factorial(s))
{ k = 0;
printf(“\t”);
while(k < s)
{printf(“%c”,argv[1][X[k]-1]);
k++;
}
c++;
}

i = s;
X[s-1] = X[s-1] + 9;
while(i > 0)
{ if(X[i-1] > 10)
{ X[i-1] = X[i-1] – 10;
X[i-2] = X[i-2] + 1;
}
i–;
}
}

printf(“\n”);

free(X);

// system(“PAUSE”);
return 0;
}

Categories: Programacion I
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: