上一页 1 2 3 4 5 6 ··· 25 下一页
摘要: 求一个正整数N的开方,要求不能用库函数sqrt(),结果的精度在0.001(创新工场笔试题)牛顿迭代公式x(n+1)=x(n)-f(x(n))/f'(x(n))求N的平方根就是求f(x)=N-x^2=0的解然后就是x2 = x1-(N-x1^2)/(-2x1)=x1/2.+N/2/x1#inc... 阅读全文
posted @ 2014-08-24 21:55 dreamsyeah 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 题目:通过键盘输入一串小写字母(a~z)组成的字符串。请编写一个字符串压缩程序,将字符串中连续出席的重复字母进行压缩,并输出压缩后的字符串。压缩规则: 1、仅压缩连续重复出现的字符。比如字符串"abcbc"由于无连续重复字符,压缩后的字符串还是"abcbc"。 2、压缩字段的格式为"字... 阅读全文
posted @ 2014-08-24 14:03 dreamsyeah 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 著名端口端口号码 / 层名称注释1tcpmuxTCP 端口服务多路复用5rje远程作业入口7echoEcho 服务9discard用于连接测试的空服务11systat用于列举连接了的端口的系统状态13daytime给请求主机发送日期和时间17qotd给连接了的主机发送每日格言18msp消息发送... 阅读全文
posted @ 2014-08-07 21:25 dreamsyeah 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 原文地址:C++空类默认函数作者:cutex定义一个空的C++类,例如class Empty{}一个空的class在C++编译器处理过后就不再为空,编译器会自动地为我们声明一些memberfunction,一般编译过去就相当于class Empty{public:Empty(); // 缺省构... 阅读全文
posted @ 2014-07-26 14:09 dreamsyeah 阅读(392) 评论(0) 推荐(0) 编辑
摘要: #include #include #include void computeLPSArray(char *pat, int M, int *lps); void KMPSearch(char *pat, char *txt){ int M =strlen(pat); int N... 阅读全文
posted @ 2014-07-16 20:44 dreamsyeah 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Pattern Searching | Set 7 (BoyerMoore Algorithm – Bad Character Heuristic)Given a text txt[0..n-1] and apattern pat[0..m-1], write a functionsearch... 阅读全文
posted @ 2014-07-16 20:41 dreamsyeah 阅读(218) 评论(0) 推荐(0) 编辑
摘要: The Naive String Matching algorithm slides the pattern one byone. After each slide, it one by one checks characters at thecurrent shift and if all ... 阅读全文
posted @ 2014-07-14 21:00 dreamsyeah 阅读(188) 评论(0) 推荐(0) 编辑
摘要: #include #include int native_string_matcher(char *str_source,char*str_pattern){int len_source = strlen(str_source);int len_pattern = strlen(str_pat... 阅读全文
posted @ 2014-07-13 17:14 dreamsyeah 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 桶排序(Bucket Sort)的原理很简单,它是将数组分到有限数量的桶子里。假设待排序的数组a中共有N个整数,并且已知数组a中数据的范围[0,MAX)。在桶排序时,创建容量为MAX的桶数组r,并将桶数组元素都初始化为0;将容量为MAX的桶数组中的每一个单元都看作一个"桶"。在排序时,逐个遍历... 阅读全文
posted @ 2014-07-13 15:07 dreamsyeah 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 希尔排序(ShellSort)是插入排序的一种,它是针对直接插入排序算法的改进。该方法又称缩小增量排序,因DL.Shell于1959年提出而得名。希尔排序实质上是一种分组插入方法。它的基本思想是:对于n个待排序的数列,取一个小于n的整数gap(gap被称为步长)将待排序元素分成若干个组子序列,... 阅读全文
posted @ 2014-07-13 12:58 dreamsyeah 阅读(126) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 25 下一页