Using below function we can find all possible combinations of any string.
static void Combination(string left, string right) { if (right.Length == 1) { Console.Write(left); Console.Write(right); Console.WriteLine(); return; } else { for (var index = 0; index < right.Length; index++) { Combination(left + right[index], right.Remove(index, 1)); } } } you can call above function like: Combination("", Console.ReadLine());
No comments:
Post a Comment