Write a Program input : string s= 'abc';;out put: [a,b,c,ab,ba,ac,bc,ca,abc]
Ravi Patel
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ConsoleApplication1 {class Program{static void Main(string[] args){string s = "abc";Console.WriteLine("Enter The Three Character:");// string ch = Console.ReadLine();char[] chabc = s.ToCharArray();for (int i = 0; i < s.Length; i++){try{string dh = s.Substring(i, 1);Console.Write(dh);Console.Write(",");}catch (Exception){// throw;}}for (int i = 0; i < s.Length; i++){for (int j = 0; j < chabc.Length; j++){if (i != j){try{Console.Write(s.Substring(i, 1));Console.Write(s.Substring(j, 1));Console.Write(",");}catch (Exception){// throw;}}}}Console.Write(s.Substring(0, 3));Console.ReadKey();}} }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace abc {class Program{static void Main(string[] args){string s = "";Console.WriteLine("Enter The Three Character:");string ch = Console.ReadLine();char[] chabc = ch.ToCharArray();ArrayList arr = new ArrayList();for (int i = 0; i < 3; i++){for (int j = 0; j < chabc.Length; j++){if (i == 0){//Console.Write(chabc[j] + ",");arr.Add(chabc[j]);}if (i == 1 && i!=j){//Console.Write(chabc[j]+""+chabc[i]+","+chabc[i]+""+chabc[j]+",");string a1 = chabc[j] + "" + chabc[i];arr.Add(a1);string a2 = chabc[i] + "" + chabc[j];arr.Add(a2);}if (i == 2 && i!=j){if (j == 0){string a1 = chabc[j] + "" + chabc[i];arr.Add(a1);string a2 = chabc[i] + "" + chabc[j];arr.Add(a2);}}}s = s + chabc[i];}arr.Add(s);int n=arr.Count;for (int i = 0; i < n; i++){Console.Write(arr[i] + ",");}Console.ReadKey();}} }