上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: 1.根据题意,编写归并排序算法,如下: bool isMerge = false; for (int step = 1; step / 2 tmpArr(2 * step); int first = i; int second = i+step; int idx = 0; int ... 阅读全文
posted @ 2015-11-22 21:17 siukwan 阅读(127) 评论(0) 推荐(0)
摘要: 1.#define LeftChild(i) (2*(i)+1)void PercDown(vector&num, int i, int n){ int child; int tmp; for (tmp = num[i]; LeftChild(i) num[child]) child++; ... 阅读全文
posted @ 2015-11-22 20:16 siukwan 阅读(129) 评论(0) 推荐(0)
摘要: 1.注意在数字和string转化过程中,需要考虑数字不是只有一位的,如300转为“300”,一开始卡在里这里,测试用例:24/8 100/1024/11 300/112.该题用到了欧几里德算法求最小公约数gcd(a,b)算法如下://欧几里德算法求最大公约数gcd,其中a>blong long gc... 阅读全文
posted @ 2015-11-22 20:02 siukwan 阅读(148) 评论(0) 推荐(0)
摘要: 1.事件模拟2.首先读取所有的汽车记录数据,筛选出合理的进入和离开时间,放到一个vector里面,对这个vector进行排序处理,进入时间早的放在前面3.对每一秒进行模拟,已经进入的车辆用一个小根堆进行存储维护,离开时间早的,排在堆顶3.取下一次进入校园车辆的时间,下一次离开校园车辆的时间,下一次查... 阅读全文
posted @ 2015-11-22 18:36 siukwan 阅读(270) 评论(0) 推荐(0)
摘要: 1.这道题目主要是求家族树中,哪一层的成员数最多,输出成员数和该层层数2.主要考察了层次遍历和数据结构的设计AC代码如下://#include//#include #include#include //#include#include#include#include//#include#includ... 阅读全文
posted @ 2015-11-22 15:35 siukwan 阅读(141) 评论(0) 推荐(0)
摘要: 1.这道题目比较有趣,我的思路如下:1)首先统计countP[i],即0~i的位置上,一共有多少个P,同理可以反向统计出countT[i],即i到n-1之间有多少个T2)遍历string,当str[i]==‘A’时,那么ans+=countP[i-1]*countT[i+1],当然, 需要根据题目要... 阅读全文
posted @ 2015-11-22 15:05 siukwan 阅读(146) 评论(0) 推荐(0)
摘要: 1.使用哈希表分别记录两串的bead数量2.需要使用迭代器进行遍历,避免出现重复情况:如ppRYYGrrYBR2258和YrR8RrY,用YrR8RrY来遍历,则前面遍历了R,后面又遍历了R,导致统计的重复AC代码://#include//#include #include#include //#i... 阅读全文
posted @ 2015-11-22 14:24 siukwan 阅读(146) 评论(0) 推荐(0)
摘要: 1.这道题目难度不大,主要思想如下:1)先构建二叉树(此时尚未填值)2)输出二叉树的中序遍历地址3)对数组进行排序4)把数组的数输入到中序遍历地址相应的节点值中AC代码://#include//#include #include#include //#include#include#include#... 阅读全文
posted @ 2015-11-22 14:05 siukwan 阅读(135) 评论(0) 推荐(0)
摘要: 1.之前一直开在测试点2里,通过实验知道0、2、4测试点是测插入排序的,1、3、5是堆排的。2.测试点2卡住,主要是因为插入排序的外层循环我从i=0开始,导致第一步出来的结果和原来的一模一样(i=0,相当于没有进行调整),而把i改为1后,则可以正常AC题目3.目前只知道测试点2的情况是,经过若干轮插... 阅读全文
posted @ 2015-11-22 13:43 siukwan 阅读(374) 评论(1) 推荐(0)
摘要: 1.主要是考察链表的删除和建表操作,使用map进行记录已经存在过的链表2.注意是删除绝对值相同的节点AC代码://#include//#include #include#include //#include#include#include#include//#include#include//#in... 阅读全文
posted @ 2015-11-22 10:02 siukwan 阅读(147) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页