效率太低就是
[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
[此贴子已经被作者于2006-11-11 10:08:34编辑过]
模擬遞歸
[CODE]
static void Main()
{
ArrayList al=new ArrayList(5);
al.Add("1");
al.Add("2");
al.Add("3");
al.Add("4");
result=(ArrayList)al.Clone();
Group(al);
result.Add("1234");
for(int i=0;i<result.Count;i++)
{
Console.Write(result[i]);
Console.Write(",,");
}
Console.ReadLine();
}
public static void Group(ArrayList al)
{
Stack s=new Stack(17);
ArrayList temp=new ArrayList(17);
ArrayList temp1=new ArrayList(al.Count);
string str="";
s.Push(al);
while(s.Count>0)
{
temp=(ArrayList)((ArrayList)s.Pop()).Clone();
temp1=(ArrayList)temp.Clone();
for(int i=0;i<temp1.Count;i++)
{
if(temp1.Count>1)
{
str="";
temp1.RemoveAt(i);
for(int j=0;j<temp1.Count;j++)
{
str+=temp1[j].ToString();
}
if(!result.Contains(str))
{
s.Push(temp1);
result.Add(str);
}
temp1=(ArrayList)temp.Clone();
}
}
}
}