C# 如何使用C中的函数绘制二叉树结构#
我已经编写了构建二叉树的函数,它可以工作,但是我不知道如何在我的界面中绘制二叉树。 我编写的查找二叉树的函数如下所示:C# 如何使用C中的函数绘制二叉树结构#,c#,C#,我已经编写了构建二叉树的函数,它可以工作,但是我不知道如何在我的界面中绘制二叉树。 我编写的查找二叉树的函数如下所示: private Node BuildTreeFromPostAndMid(string Post, string Mid) { char genc=Post[Post.Length - 1]; Node gen = new Node(genc); string[] s = Mid.Split(genc); if (s[0] != "")
private Node BuildTreeFromPostAndMid(string Post, string Mid)
{
char genc=Post[Post.Length - 1];
Node gen = new Node(genc);
string[] s = Mid.Split(genc);
if (s[0] != "")
{
int l1 = s[0].Length;
string newh = "";
for (int i = 0; i < Post.Length - l1 + 1; i++)
{
if (IsSame(Post.Substring(i, l1), s[0]))
{
newh = Post.Substring(i, l1);
}
}
gen.lc = BuildTreeFromPostAndMid(newh, s[0]);
}
else gen.lc = null;
if (s[1] != "")
{
int l2 = s[1].Length;
string newh = "";
for (int i = 0; i < Post.Length - l2 + 1; i++)
{
if (IsSame(Post.Substring(i, l2), s[1]))
{
newh = Post.Substring(i, l2);
}
}
gen.rc = BuildTreeFromPostAndMid(newh, s[1]);
}
else gen.rc = null;
return gen;
}
private节点BuildTreeFromPostAndMid(字符串Post,字符串Mid)
{
char genc=Post[Post.Length-1];
节点gen=新节点(genc);
字符串[]s=Mid.Split(genc);
如果(s[0]!=“”)
{
int l1=s[0]。长度;
字符串newh=“”;
对于(int i=0;i
在UI中,用户可以输入Post-order和mid-order遍历二叉树系列,我应该在界面的某个地方绘制树(我没有足够的信用来上传我的图片,所以我键入它,希望你能理解我说的话)几年前我在Silverlight、WPF和WinForms中做了类似的事情。你有多种选择
这完全取决于“接口”用于框架的内容。WPF、WinForms、GTK、ASP等…我的文件名是WPF,所以我想它可能是WPF。那么也许我们帮不上忙。