摘要: 引用:http://blog.csdn.net/hackbuteer1/article/details/6686263题目:输入一个字符串,输出该字符串中对称的子字符串的最大长度。比如输入字符串“google”,由于该字符串里最长的对称子字符串是“goog”,因此输出4。算法一:O(n^3)判断字串是否对称是从外到里, O(n)#include <stdio.h>#include <string.h>/* *判断起始指针,到结束指针的字符串是否对称 */int IsSymmetrical(char* pBegin, char* pEnd){ if(pBegin == N 阅读全文
posted @ 2013-03-06 14:32 wouldguan 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 引用:http://www.cppblog.com/guyuecanhui/articles/76443.html问题描述:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列,求最后一个出列人的编号。代码:#include <stdio.h>int josephus(int n, int m, int start){ int k = 1; for(int i=2; i<=n; i++) k = (k+m-1)%i + 1; . 阅读全文
posted @ 2013-03-06 12:37 wouldguan 阅读(167) 评论(0) 推荐(0) 编辑