1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
char combi[] = "abcdefghijklmnopqrstuvwxyz";
int bool=1;
void faire_combi(char * str, char * tmp, int len, int ind);
void faire_combi(char * str, char * tmp, int len, int ind) {
int i;
if (ind >= len) {
printf("%s\n",tmp);
return;
}
for (i = 0; i < strlen(combi); i++) {
tmp[ind] = str[i];
if(bool == 1)
{
strcpy(tmp,"naaaaa");
bool = 0;
}
faire_combi(str, tmp, len, ind+1);
}
}
int main(void) {
int len = 6;
//nvdia
char * tmp = calloc(len + 1, sizeof(char));
faire_combi(combi, tmp, len, 0);
return 0;
} |
Partager