我在网上看到了这个问题,我试图在C++. 我有以下算法:
char permutations( const char* word ){
  int size = strlen( word );
  if( size <= 1 ){
      return word;
  }
  else{
    string output = word[ 0 ];
    for( int i = 0; i < size; i++ ){
        output += permutations( word );
        cout << output << endl;
        output = word[ i ];
     }
  }
  return "";
}
例如,如果我有abc输入,我想显示abc, acb, bac, bca, cab, cba。所以,我想做的是
'abc' => 'a' + 'bc' => 'a' + 'b' + 'c'
                    => 'a' + 'c' + 'b'
所以我需要在每个函数调用中传递一个wordless char。有人可以帮忙怎么做吗?