#include
#include
char dest[50]; void Reverse_str(char *src, int hight, int *count); int main() { char str[] = "abcde"; int count = 0; printf("The previous string is :/n"); puts(str); printf("----------------/n"); Reverse_str(str, 0, &count); printf("/nThere %d assign ways!/n", count); return 0; } void Reverse_str(char *src, int hight, int *count) { int len = strlen(src); int i = 0, j = 0; char *pstr = NULL; pstr = src; if(hight == len) { for(i = 0; i < len; ++i) { putchar(dest[i]); } printf("/t"); (*count)++; if((*count) % 8 == 0) { printf("/n"); } return; } while(*pstr != '/0') { for(j = 0; j < hight; ++j) { if(*pstr == dest[j]) { break; } } if(j >= hight) { dest[hight] = *pstr; Reverse_str(src, hight+1, count); } pstr++; } }
打印一个字符串中字符的所有组合
最新推荐文章于 2022-05-18 10:19:12 发布