仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 641|回复: 8
打印 上一主题 下一主题

[学习教程] ASP.NET编程:C#非递回体例完成分列组合

[复制链接]
飘飘悠悠 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:18:06 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
一个很大的类库。应用程序之所以难以跨平台,在于直接调用了特定平台的接口,而一个巨大的类库,就能极大地减少应用程序对平台的依赖。C#以非递回体例完成三位分列组合,以下代码:
  1. //深度优先classProgram{staticvoidMain(string[]args){int[]number=newint[]{1,3,5,7};Listdata=newList();StackopenStack=newStack();Treeroot=newTree();Treeparent=root;while(true){if(parent.GetDeep()==4){parent.printf();}else{vartempSon=number.ToList();foreach(varitemintempSon){TreeNode=newTree();Node.NodeData=item;Node.Parent=parent;openStack.Push(Node);}}if(openStack.Count==0)break;varitemData=openStack.Pop();parent=itemData;}System.Console.Read();}publicstaticvoidprintf(Listdata){stringd="";data.ForEach(p=>d=d+p);System.Console.WriteLine(d);}}classTree{publicTreeParent;publicintNodeData;publicListSon=newList();publicintGetDeep(){inti=0;varp=this;while(true){if(p==null){returni;}else{p=p.Parent;i++;}}}publicvoidprintf(){stringpf="";varp=this;while(true){if(p==null){System.Console.WriteLine(pf);return;}else{if(p.NodeData!=0){pf=p.NodeData+pf;}p=p.Parent;}}}}//广度优先classProgram{staticvoidMain(string[]args){int[]number=newint[]{1,3};List<int>data=newList<int>();Stack<Tree>openStack=newStack<Tree>();Queue<Tree>openQueue=newQueue<Tree>();Treeroot=newTree();Treeparent=root;while(true){if(parent.GetDeep()==4){parent.printf();}else{vartempSon=number.ToList();foreach(varitemintempSon){TreeNode=newTree();Node.NodeData=item;Node.Parent=parent;//openStack.Push(Node);openQueue.Enqueue(Node);}}if(openQueue.Count==0)//if(openStack.Count==0)break;varitemData=openQueue.Dequeue();//openStack.Pop();parent=itemData;}System.Console.Read();}publicstaticvoidprintf(List<int>data){stringd="";data.ForEach(p=>d=d+p);System.Console.WriteLine(d);}}classTree{publicTreeParent;publicintNodeData;publicList<Tree>Son=newList<Tree>();publicintGetDeep(){inti=0;varp=this;while(true){if(p==null){returni;}else{p=p.Parent;i++;}}}publicvoidprintf(){stringpf="";varp=this;while(true){if(p==null){System.Console.WriteLine(pf);return;}else{if(p.NodeData!=0){pf=p.NodeData+pf;}p=p.Parent;}}}}
复制代码
我以前很喜欢Serv-U,自从它用Java重写之后我就再也没用过,实在是太慢了,我宁可用IIS搭建FTP,虽然IIS搭建FTP在权限管理上很不灵活。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-9-20 22:59

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表