11-23-2005, 08:30 AM
I found this:
#include <stdio.h>
#include <stdlib.h>
#define forever for( ; ; )
int main(void)
{
int n, m, i, nuevo_valor, *comb;
n = 6;
m = 3;
comb = malloc(m*sizeof(int));
if (comb == NULL){
puts("Puntero nulo.");
return EXIT_FAILURE;
}
for(i = 0; i < m; ++i)
comb[i] = i + 1;
forever {
putchar('\n');
for (i = 0; i < m; ++i)
printf("%d", comb[i]);
for (i = m - 1; i > -1 && comb[i] == n - ((m - 1) - i); --i)
;
if (i == -1)
return EXIT_SUCCESS;
nuevo_valor = ++comb[i];
while (i < m)
comb[++i] = ++nuevo_valor;
}
but I don't know how convert it.
#include <stdio.h>
#include <stdlib.h>
#define forever for( ; ; )
int main(void)
{
int n, m, i, nuevo_valor, *comb;
n = 6;
m = 3;
comb = malloc(m*sizeof(int));
if (comb == NULL){
puts("Puntero nulo.");
return EXIT_FAILURE;
}
for(i = 0; i < m; ++i)
comb[i] = i + 1;
forever {
putchar('\n');
for (i = 0; i < m; ++i)
printf("%d", comb[i]);
for (i = m - 1; i > -1 && comb[i] == n - ((m - 1) - i); --i)
;
if (i == -1)
return EXIT_SUCCESS;
nuevo_valor = ++comb[i];
while (i < m)
comb[++i] = ++nuevo_valor;
}
but I don't know how convert it.