上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页
摘要: Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-07-03 07:55 朱传林 阅读(180) 评论(0) 推荐(0)
摘要: 博客积分是衡量博客水平的重要标准,博客的排名也将按照积分排列。积分规则具体如下:1、每发布一篇原创或者翻译文章:可获得10分2、每发布一篇转载文章:可获得2分3、博主的文章每被评论一次:可获得1分4、每发表一次评论:可获得1分(自己给自己评论、博主回复别人对自己博文的评论不获得积分)5、每篇博文阅读... 阅读全文
posted @ 2015-07-02 15:52 朱传林 阅读(263) 评论(0) 推荐(0)
摘要: Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文
posted @ 2015-07-02 09:08 朱传林 阅读(146) 评论(0) 推荐(0)
摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr... 阅读全文
posted @ 2015-07-02 09:05 朱传林 阅读(111) 评论(0) 推荐(0)
摘要: /*字符串匹配*/#includeusing namespace std;void get_next(string T,int *next){//朴素算法 int i,j; i=1; j=0; next[1]=0; while(iT.length()) return i-T.length(); e... 阅读全文
posted @ 2015-07-01 16:41 朱传林 阅读(126) 评论(0) 推荐(0)
摘要: 主要是栈的应用,里面有两个函数deleteSpace(),stringToDouble()在我另一篇博客当中:对string的一些扩展函数。 本程序只是基本的功能实现,没有差错控制。#include#include#include#include#include"fstring.h"/* ... 阅读全文
posted @ 2015-07-01 14:41 朱传林 阅读(168) 评论(0) 推荐(0)
摘要: 排序算法复习大致结束了,主要有以下几种:冒泡排序、选择排序、简单插入排序、希尔排序、归并排序、快速排序、堆排序。#include #define MAXSIZE 1000using namespace std;class SqList{public: SqList():length(0){} Sq... 阅读全文
posted @ 2015-06-30 08:43 朱传林 阅读(192) 评论(0) 推荐(0)
摘要: 堆的定义:1)完全二叉树,2)每个结点的值都大于其左右孩子结点的值。根据堆的定义可知,最大值就是根结点,其次就是根结点左右孩子结点中的一个…… 堆排序有两个很重要的过程:1)建堆,2)堆维护。实质上,这两个过程都可以通过一个函数来实现。void HeapAdjust(SqList* l... 阅读全文
posted @ 2015-06-30 08:41 朱传林 阅读(152) 评论(0) 推荐(0)
摘要: 快速排序将以枢轴为界,将原数组分为两个部分,枢轴以前,值都小于枢轴的值,枢轴以后的值都大于枢轴。 采用递归的方法,对以枢轴为界的两个子序列进行快速排序,直至子序列长度为1。 1、快速排序的关键是枢轴的选取,主要有三种方法:1)选取第一个或最后一个作为枢轴值;2)采用随机数生成器,生成枢... 阅读全文
posted @ 2015-06-30 07:59 朱传林 阅读(285) 评论(0) 推荐(0)
摘要: 归并排序原理即将两个有序的数组合并成一个,归并排序有两种方法:递归和循环。/*递归方法*/void Merge(int TR1[], int TR2[], int low, int mid, int high){//将TR2归并入TR1中 int pos1 = low; int pos2 = mid... 阅读全文
posted @ 2015-06-29 16:46 朱传林 阅读(154) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页