![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
linken_xihe
这个作者很懒,什么都没留下…
展开
-
KMP算法中核心的代码
#include #include #include #include using namespace std;void get_next(string T, int *next){ int i = 1, j = 0; next[1] = 0; while (i { //cout if原创 2012-06-10 12:22:56 · 217 阅读 · 0 评论 -
知道随机产生1-7的函数,如何得到随机产生1-10的函数
题目:http://chaotang0281.iteye.com/blog/1179205 已知有个rand7()的函数,它可以返回1到7之间的随机自然数,现在请让利用这个rand7()来构造rand10()使它能 随机地产生1~10之间的自然数。想的结果: 1、主要是要保证各个数产生的概率一致。 2、如果rand7()已知,求rand5()就原创 2012-05-23 22:09:40 · 365 阅读 · 0 评论 -
大数相加的算法
有次周五失眠,尝试下了下大数相加的算法。这个周末再优化下,先露露脸。#include #include #include #include using namespace std;char num1[] = "+1030000000000910";char num2[] = "+10";int strlen1 = strlen (num1);原创 2012-05-24 22:19:20 · 240 阅读 · 0 评论 -
折半查找
整理下以前写过的练习代码,陆续放到网上。#include #include using namespace std;#define long 5bool Binarysearch(int *a, int iFind){ if ((iFind a[long - 1])) return false;原创 2012-05-24 21:25:20 · 209 阅读 · 0 评论