随笔分类 -  算法

编程核心
摘要:输入:abcabcabc输出:3classProgram{staticvoidMain(string[]args){stringstr="abcdfabcdfabcdfabcdfabcdfabcdf";string[]substr=newstring[100];stringsubstrValue;boolsame=false;for(inti=0;i<str.Length;i++){if(str.Length%(i+1)==0&&i!=0){intj=0;intk=0;while(k+i<str.Length){substr[j]=str.Sub 阅读全文
posted @ 2012-05-09 00:46 盈不足 阅读(323) 评论(0) 推荐(0)
摘要:在n*n的方阵填入1,2,3……n*n.最后形成蛇形。例如n=4时的方阵为:其中(n<=8)10 11 12 19 1613 28 15 14 37 6 5 4源程序如下:usingSystem;namespaceTestConsole{classProgram{staticvoidMain(string[]args){int[,]snake=newint[9,9];Console.Write("Input:");intn=int.Parse(Console.ReadLine());intx=0;inty=n-1;snake[x,y]=1;intnumber=1;wh 阅读全文
posted @ 2012-05-08 00:34 盈不足 阅读(187) 评论(0) 推荐(0)
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--/**CreatedbySharpDevelop.*User:Administrator*Date:2010/4/9*Time:15:06*Directions:最大匹配分词算法**Tochanget... 阅读全文
posted @ 2010-04-09 18:22 盈不足 阅读(299) 评论(0) 推荐(0)
摘要:问题描述:有N个灯,(每个灯只有一个开关,按一下开,再按一下关)来了K个人,第一个人把所有灯都打开,第二个人按下了所有编号为2的倍数的灯的开关,第三个人按下所有编号为3的倍数的灯的开关……按此规律。问最后那些灯亮着?输入:7 3 输出:1 5 6 7 代码 Code highlighting produced by Actipro CodeHighlighter (free... 阅读全文
posted @ 2009-12-20 18:25 盈不足 阅读(808) 评论(0) 推荐(2)
摘要:输入:由n个数构成的一个序列(a1,a2,a3,……an)中(a1≠a2≠a3≠……≠an)且任意an≤n输出:重新排列的序列(b1,b2,b3,……bn),使得b1<b2<b3<……<an示例:输入->5 8 1... 阅读全文
posted @ 2009-08-20 20:55 盈不足 阅读(691) 评论(0) 推荐(0)
摘要:[代码] 阅读全文
posted @ 2009-08-16 00:37 盈不足 阅读(521) 评论(0) 推荐(0)
摘要:[代码] 阅读全文
posted @ 2009-08-02 01:00 盈不足 阅读(281) 评论(0) 推荐(0)