using System; using System.Collections.Generic; public class Program { List l; Program() { l = new List(); } void swap(ref char a, ref char b) { if (a == b) return; char tmp; tmp = b; b = a; a = tmp; } public void go(char[] list, int k, int m) { int i; if (k == m) { Console.WriteLine(list); //if(!(l.Contains(list))) l.Add(list); } else for (i = k; i <= m; i++) { swap(ref list[k], ref list[i]); go(list, k + 1, m); swap(ref list[k], ref list[i]); } } public void print_list() { foreach (char[] a in l) Console.WriteLine(a); } static void Main(string[] args) { Console.Write("input= "); string s = Console.ReadLine(); Program p = new Program(); char[] c = s.ToCharArray(); Console.WriteLine("output= "); p.go(c,0,(c.Length-1)); p.print_list(); Console.ReadKey(); } }