递归算法创建树
来源:互联网 发布:阿里云备案订单查询 编辑:程序博客网 时间:2024/05/05 02:58
代码如下:
namespace Smartkid.ESchool.Web.UserControl
...{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections;
/**//// <summary>
/// Summary description for BuildMenuTree.
/// </summary>
public class BuildMenuTree : System.Web.UI.UserControl
...{
int index = 0;
private void Page_Load(object sender, System.EventArgs e)
...{
// Put user code to initialize the page here
BuildTree(1);
}
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
...{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
...{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void BuildTree(int pPID)
...{
if(BusinessFacade.Service.II_Menu_Service.Instance.GetSubMenu(pPID) != null && BusinessFacade.Service.II_Menu_Service.Instance.GetSubMenu(pPID).Count>0)
...{
IList iList = BusinessFacade.Service.II_Menu_Service.Instance.GetII_MenuListByPID(pPID);
int id = 0;
index++;
foreach(BusinessFacade.II_Menu iI_Menu in iList)
...{
if(iI_Menu.ID != pPID)
...{
id++;
Response.Write(index.ToString()+iI_Menu.Name+""id=""+id.ToString()+"<br>");
BuildTree(iI_Menu.ID);
}
}
index--;
}
}
}
}
...{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections;
/**//// <summary>
/// Summary description for BuildMenuTree.
/// </summary>
public class BuildMenuTree : System.Web.UI.UserControl
...{
int index = 0;
private void Page_Load(object sender, System.EventArgs e)
...{
// Put user code to initialize the page here
BuildTree(1);
}
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
...{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
...{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void BuildTree(int pPID)
...{
if(BusinessFacade.Service.II_Menu_Service.Instance.GetSubMenu(pPID) != null && BusinessFacade.Service.II_Menu_Service.Instance.GetSubMenu(pPID).Count>0)
...{
IList iList = BusinessFacade.Service.II_Menu_Service.Instance.GetII_MenuListByPID(pPID);
int id = 0;
index++;
foreach(BusinessFacade.II_Menu iI_Menu in iList)
...{
if(iI_Menu.ID != pPID)
...{
id++;
Response.Write(index.ToString()+iI_Menu.Name+""id=""+id.ToString()+"<br>");
BuildTree(iI_Menu.ID);
}
}
index--;
}
}
}
}
- 递归算法创建树
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 二叉树创建及遍历算法(递归及非递归)
- 算法源码之非递归创建/遍历二叉树
- 数据结构和算法--二叉树创建和递归遍历
- 同心源超级备忘录
- DELPHI常用函数快速查询
- J2ME Timer 使用指南
- 深入浅出之正则表达式
- delphi 常用属性、方法、事件
- 递归算法创建树
- 一个有用的log4j.properties文件模板
- 在J2ME中使用Timer和TimerTask来实现多线程
- 我们很郁闷!
- 常用log4j配置
- java(JSP)读写文件操作
- AJAX学习目录
- 网页设计必然趋势:DIV+CSS
- 将闪存改造为系统加密狗