110,537
社区成员
发帖
与我相关
我的任务
分享
string[] 序列 = { "1", "1#2", "1#2#3", "1#2#3#4", "1#2#5", "1#2#5#6" };
int[] 组号= { 1, 2, 3, 4, 5, 6 };
Enumerable.Repeat(i == 0 ? "" : " ", i + 1).Aggregate((s1, s2) => string.Format("{0}{1}", s1, s2)) + (i == 0 ? "" : "┗");
public static string getTabStr(int i)
{
return Enumerable.Repeat(i == 0 ? "" : " ", i + 1).Aggregate((s1, s2) => string.Format("{0}{1}", s1, s2)) + (i == 0 ? "" : "┗");
}
static void Main(string[] args)
{
string[] List = { "1", "1#2", "1#2#3", "1#2#3#4", "1#2#5", "1#2#5#6" };
Dictionary<string, int> _l = new Dictionary<string, int>();
foreach (string s in List)
{
if (s.IndexOf("#") > -1)
_l.Add(s.Split('#').Last(), s.Length - s.Replace("#", "").Length);
else
_l.Add(s, Convert.ToInt32(s));
}
foreach (var D in _l)
{
Console.WriteLine(getTabStr(D.Value) + D.Key);
}
/*
┗1
┗2
┗3
┗4
┗5
┗6
*/