重複の可能性:
特定の文字列のセットを入力する方法
文字列の順列を入力しようとしています。たとえば、文字列 "123" は 123 132 213 231 321 312 を与えるはずです コードを修正するには助けが必要です
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestAAD
{
class Program
{
static int len = 0;
static int lenPerm = 0;
private static void Permutations(string str, string perm , int i)
{
if (i == len) Console.WriteLine(perm);
for (int k = 0; k < len; k++)
{
lenPerm = perm.Length;
for (int j = 0; j < lenPerm; j++)
{
if ((perm[j] == str[(len - 1) - k]) && (len-1-k>0))
k++;
}
if((len-1-k) >=0)
Permutations(str, perm + str[(len - 1) - k], i++);
}
}
static void Main(string[] args)
{
string st = "123";
len = st.Length;
Permutations(st, "",0);
}
}
}
誰かが私を助けることができれば、お願いします