摘要:
1#include<iostream>2#include<string>3usingnamespacestd;45#defineMAXN1067structNode8{9intindex;10Node*next;11};1213classYSF14{15public:16intn;//规模17intm;18Node*top;19Node*bottom;20Node*t;21YSF(intln,intlm)22{23n=ln;24m=lm;25top=newNode();26bottom=top;27top->index=0;28for(inti=1;i<n; 阅读全文
posted @ 2011-09-17 23:36
Eric.wei
阅读(937)
评论(0)
推荐(0)
摘要:
一段字符串中提取最长的回文长度:浅显易懂的想法就是假设任何一个位置的字符为回文中心,进行两个方向的扩散,进而提取最长回文。这是最朴素的想法:代码如下:1#include<iostream>2#include<string>3usingnamespacestd;45charstr[100]="abbbbaaa";678//如果是回文长度是偶数个9intgetMidtwoNum(char*s,intlength,intindex)10{11intre=1;12intt=index,b=index+1;13while(t>=0&&b& 阅读全文
posted @ 2011-09-17 23:06
Eric.wei
阅读(986)
评论(0)
推荐(0)
摘要:
给定一个数组input[] ,如果数组长度n为奇数,则将数组中最大的元素放到 output[] 数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元素放到 output[] 数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input[] = {3, 6, 1, 9, 7} output[] = {3, 7, 9, 6, 1}; input[] = {3, 6, 1, 9, 7, 8} output[] = {1, 6, 8, 9, 7, 3}题目考察的是排序+规格化输出:容易让人理解的解法,首先进行排序,进而 阅读全文
posted @ 2011-09-17 20:55
Eric.wei
阅读(1350)
评论(0)
推荐(0)
摘要:
另外更新的2012华为题库地址链接如下:2012华为机试排序题目2012华为2011年9月17日上机题目之最长回文2012华为2011年9月17日上机题目之约瑟夫环模拟法实现程序2012中兴南京笔试试题大题汇总及参考程序地区一:1. 编写函数string deletestring(string str,string sub_str)从str中查找匹配的字符串sub_str,采用最左匹配,且输出形式为str+"_"+匹配的次数题目一的意思应该是求解字符串str中子字符串sub_str的个数,同时输出形式采用原字符串+"_"匹配次数相信大家第一反应应该是采用 阅读全文
posted @ 2011-09-17 13:13
Eric.wei
阅读(3453)
评论(1)
推荐(0)

浙公网安备 33010602011771号