저는 C#에 익숙하지 않아이 작업을 가지고 있습니다 :실종 된 조합
나는 신원이 확인되지 않은 사람 (예 : 5 명)의 목록을 가지고 있습니다. 이 작업은 목록에있는 사람과 그 사람이 같은 그룹에 속할 수없는 사람들의 그룹을 얻는 것입니다.
EX : 5명
{1}, {2} {3} {4} {5}, {1,3}, {1,4}, {1,5} {2,4}, {2,5}, {3,5}, {1,3,5}
제가 링크 http://www.codeproject.com/Articles/26050/Permutations-Combinations-and-Variations-using-C-G 에서 결합 방법을 사용하고이 코드가
private void button3_Click(object sender, EventArgs e)
{
outputBox.Clear();
int nr = Convert.ToInt32(nmbrBox.Value);
double tmp = Math.Pow(2, nr);
double combs = tmp - 1;
List<int> list = new List<int>();
for (int i = 1; i <= nr; i++)
{
list.Add(i);
}
outputBox.AppendText(combs.ToString() + " combinari\n\n");
List<string> allCombinations = new List<String>();
for (int i = 1; i <= list.Count; i++)
{
var combis = new Facet.Combinatorics.Combinations<int>(list, i, Facet.Combinatorics.GenerateOption.WithoutRepetition);
allCombinations.AddRange(combis.Select(c => string.Join("", c)));
}
foreach (var combi in allCombinations)
{
outputBox.AppendText(combi + "\n");
}
}
내가 원하는 결과 만 표시하도록하려면 어떻게해야합니까?
:
이것은 다음과 같은 결과를 제공합니다 :이 경우 입력은 이름의 배열은? 적법한 가치를 결정하기 위해 조합을 어떻게 필터링하고 있습니까? – StarPilot
변수를 사용하고 [i + 1] = number [i] +1의 숫자를 확인할 수 있도록 "allCombinations"에서 조합을 가져 오려고했습니다. –