我很不确定为什么当我输入 6 个或更多数字/字符时我的代码会这样做,它只显示一些输出。(我知道数字/字符不会影响任何东西)。
例如,如果我输入 cat 它会列出所有可能的变化: cat cta act atc tac tca
但是当我输入 123456(或任何 6+ 个字母的字符串)时:它开始显示在 462513-612345(如果你知道我的意思的话)。其余的(123456-462513)怎么了?
    #include <stdio.h>
    #include <string.h>
    void swap (char *X, char *Y)
    {
      char Z;
      Z = *X;
      *X = *Y;
      *Y = Z;
    }
    void mixmatch (char *A, int i, int n)
    {
      int j;
      if (i == n)
         printf("%s\n", A);
      else
      {
         for (j = i; j <= n; j++)
         {
            swap((A+i), (A+j));
            mixmatch(A, i+1, n);
            swap((A+i), (A+j));
         }
      }
    }
    int main()
    {
       char A[100];
       printf ("Enter the string/set of numbers: ");
       gets(A);
       int k;
       k=strlen(A);
       mixmatch(A, 0, k-1);
    return 0;
    }
    
