随笔分类 -  Play Algorithm

Just for funny
摘要:publicclassCombination{List<string>Array=null;publicCombination(List<string>array){Array=array;}publicvoidPrintCombination(){foreach(stringsinCombinate(0)){Console.WriteLine(s);}}privateList<string>Combinate(intstartIndex){if(startIndex>=Array.Count)returnnewList<string>() 阅读全文
posted @ 2012-02-22 16:20 xpwilson 阅读(247) 评论(0) 推荐(0)
摘要:publicclassSBinaryTree{publicintValue;publicSBinaryTreeLeftChild;publicSBinaryTreeRightChild;publicSBinaryTree(intvalue,SBinaryTreeleft,SBinaryTreeright){Value=value;LeftChild=left;RightChild=right;}}//SBinaryTreem=newSBinaryTree(4,null,null);//SBinaryTreea=newSBinaryTree(4,m,null);//SBinaryTreeb=ne 阅读全文
posted @ 2011-12-18 18:07 xpwilson 阅读(326) 评论(0) 推荐(0)
摘要:题目:在数组中,数字减去它右边的数字得到一个数对之差。求所有数对之差的最大值。例如在数组{2, 4, 1, 16, 7, 5, 11, 9}中,数对之差的最大值是11,是16减去5的结果。publicclassMaxDiffer{/*Calculatethemaxvaluewhichisgeneratedbythenumbersubstract*thenumberwhichisintherightsideofthearray**/privateint[]arrayNumbers=null;publicMaxDiffer(int[]array){arrayNumbers=array;}publi 阅读全文
posted @ 2011-12-18 16:11 xpwilson 阅读(505) 评论(0) 推荐(0)
摘要:publicclassMatchSettor{/*Eachteamneedtoplayagamewithanotherteam.*Oneteamcanonlyplayonceinoneday*NeedtocompletethegameinintTeamNumber-1day*/intintTeamNumber=2;//TeamNum>=2;intintDayNumber=1;TeamSet[,]array=null;publicMatchSettor(intteamNum){intTeamNumber=teamNum;intDayNumber=teamNum-1;array=newTea 阅读全文
posted @ 2011-11-30 20:36 xpwilson 阅读(209) 评论(0) 推荐(0)
摘要:publicclassHANOI{publicvoidHanoi(intn,stringa,stringb,stringc){if(n==1){Move(n,a,c);}else{Hanoi(n-1,a,c,b);Move(n,a,c);Hanoi(n-1,b,a,c);}}privatevoidMove(intn,stringi,stringj){Console.WriteLine("Movedisk{0}from{1}to{2}",n,i,j);}} 阅读全文
posted @ 2011-11-28 23:23 xpwilson 阅读(161) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Reflection;using Microsoft.Practices 阅读全文
posted @ 2010-08-23 17:24 xpwilson 阅读(146) 评论(0) 推荐(0)