基于C的windows窗體中二叉树的绘制和哈夫曼编码的编制问题.docx

基于C的windows窗體中二叉树的绘制和哈夫曼编码的编制问题.docx

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
基于C的windows窗體中二叉树的绘制和哈夫曼编码的编制问题

PAGE \* MERGEFORMAT5 二叉树的绘制及哈夫曼树字符串的替换编程思路 搜索二叉树: 二叉树的绘制: 绘图代码: //绘制二叉树 public void paixu() { 提取值得个数 int numofall =dt.Rows.Count; //声明标签数组存放节点 Label[] L = new Label[numofall];; int high=0; for (int i = 0; inumofall ; i++) { //给标签赋值 int valofcell0, valofcell1,n; valofcell0 = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString()); valofcell1 = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value.ToString()); L[i] = new Label(); L[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;//标签加框 L[i].Text = valofcell0 + , + valofcell1; string b = a.WriteOut(valofcell0) + valofcell0; string [] data = b.Replace(-, -).Split(-); n =data .Count (); //获取树高度 if (n high) { high = n; } } //给定各点的坐标 int gc = Convert.ToInt32(Math.Pow(2, high)) * 20, gt = 38; Form10 f = new Form10(); L[0].Location = new Point(gc, gt);//给定根节点 f.Controls.Add(L[0]); ShapeContainer can = new ShapeContainer(); for(int i=1;inumofall ;i++) { int valofcell0, n,x,y; valofcell0 = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString()); string b = a.WriteOut(valofcell0) + valofcell0; string[] data = b.Replace(-, -).Split(-); n = data.Count(); x = gc; y = gt; int j; for ( j = 0; j n - 1; j++) { if (Convert.ToInt32(data[j]) Convert.ToInt32(data[j + 1])) { x= x + Convert .ToInt32(Math .Pow (2,high-j-1))*20;

文档评论(0)

fglgf11gf21gI + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档