1.简单数组
string[] arrSingle=new string[]{A,A,B,B,C}
对这个数组进行全排列,如何把不重复的值计算出来. 如:AABBC,ABABC,....2.复杂数组
string[,] arrData=new string[]{{A,A’},{A,A’},{B,B’},{B,B’},{C,C’}}
{A,A’}两个里面取1个排列如A或A’,{B,B’}和其它也一样的取法 对这个数组进行全排列,如何把不重复的值计算出来. 如:AABBC,A’ABBC,...
谢谢
string[] arrSingle=new string[]{A,A,B,B,C}
对这个数组进行全排列,如何把不重复的值计算出来. 如:AABBC,ABABC,....2.复杂数组
string[,] arrData=new string[]{{A,A’},{A,A’},{B,B’},{B,B’},{C,C’}}
{A,A’}两个里面取1个排列如A或A’,{B,B’}和其它也一样的取法 对这个数组进行全排列,如何把不重复的值计算出来. 如:AABBC,A’ABBC,...
谢谢
{
System.Collections .ArrayList list=new System .Collections .ArrayList ();// 不重复出现的字符串加到该数组
this.ListBox1 .Items .Clear ();
string[] arrSingle=new string[]{"A","A","B","B","C"} ;
System.Collections .Hashtable ht=new Hashtable ();
foreach(string xx in arrSingle)
{
if( ht.Contains (xx))
ht[xx]=((int)ht[xx])+1;
else
ht[xx]=1;
}
//////////////把字符串和字符串重复的次数显示在ListBox中
foreach(DictionaryEntry item in ht)
{
string text="字符串为: "+item.Key. ToString () +" 在字符集合中出现的词数为:" +item.Value .ToString ()+ " 次";
this.ListBox1 .Items .Add (text);
}
/////////////////////////把不重复出现的字符串增加到list中
foreach(DictionaryEntry item in ht)
{
if((int)item.Value==1)
{
list.Add (item.Key .ToString ());
}
}
}