static string[] m_Data = { "A", "B", "C", "D", "E" };
static void Main(string[] args)
{
Dictionary dic = new Dictionary();
for (int i = 0; i < m_Data.Length; i++)
{
Console.WriteLine(m_Data[i]);//如果不需要打印单元素的组合,将此句注释掉
dic.Add(m_Data[i], i);
}
GetString(dic);
Console.ReadLine();
}
static void GetString(Dictionary dd)
{
Dictionary dic = new Dictionary();
foreach (KeyValuePair kv in dd)
{
for (int i = kv.Value + 1; i < m_Data.Length; i++)
{
Console.WriteLine(kv.Key + m_Data[i]);
dic.Add(kv.Key + m_Data[i], i);
}
}
if (dic.Count > 0) GetString(dic);
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-555234/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12639172/viewspace-555234/