110,577
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
string[] array = new string[] { "A", "B", "C", "D", "E" };
//int s = array.Length;
for (int j = 0; j < 4; j++)
{
for (int s = array.Length; s >= 2+j; s--)
{
for (int i = j; i < s; i++)
{
Console.Write(array[i]);
}
Console.WriteLine();
}
}
Console.ReadLine();
}
static string[] m_Data = { "A", "B", "C", "D", "E" };
static void Main(string[] args)
{
for (int i = 0; i < m_Data.Length; i++)
{
for (int j = i + 1; j < m_Data.Length; j++)
{
OutPut(i, j);
}
}
}
private static void OutPut(int i, int j)
{
string temp = string.Empty;
for (int k = i; k <= j; k++)
{
temp += m_Data[k];
}
Console.WriteLine(temp);
}
static string[] m_Data = { "A", "B", "C", "D", "E" };
static void Main(string[] args)
{
Dictionary<string, int> dic = new Dictionary<string, int>();
for (int i = 0; i < m_Data.Length; i++)
dic.Add(m_Data[i], i);
GetString(dic);
Console.ReadLine();
}
static void GetString(Dictionary<string,int> dd)
{
Dictionary<string, int> dic = new Dictionary<string, int>();
foreach (KeyValuePair<string, int> 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);
}