#include <stdio.h> #include <stdlib.h> #include <string.h> //显示字符串的全排列组合 void DisAllStrExt (char * str, int low, int high) { int index; if (low >= high - 1) { for (index = 0; index < high; index++) putchar(str[index]); puts("\r\n"); } else { for (index = low; index < high; index++) { char c = str[low]; str[low] = str[index]; str[index] = c; DisAllStrExt(str, low + 1, high); c = str[low]; str[low] = str[index]; str[index] = c; } } } int main () { char str[] = "abcd"; DisAllStrExt(str, 0, strlen(str)); return 0; }