摘要: first, i use exhausitive search. however, it will exceed the time limit. the time speed is O(n^2) then, i change the strategy. for impove the speed, I 阅读全文
posted @ 2017-07-18 18:24 hahahaf 阅读(176) 评论(0) 推荐(0) 编辑
摘要: a collocation is two or more words that often go together. These combination just sound "right" to native english speaker. 'commit a crime' is a typic 阅读全文
posted @ 2017-07-17 19:34 hahahaf 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 三种情况: “a” 对应"a", "." 对应 "a" "a*" 对应 “aa” 当p为空,s为空时可以匹配; 若p的第二个字符为*,第一情况为不匹配(b, a*b);从 (b,b)开始匹配 第二种情况为匹配(a, a*); 首元素相同, 从( ,a*)开始匹配 若p的第二个字符不为*, 首字符必须 阅读全文
posted @ 2017-07-17 18:29 hahahaf 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 判断回文(recursive) 两个条件: string中*s.end() 是‘\0’. 不使用递归: 得到最长的子回文字符串,最简单的做法得到所有字符串是否回文,记录长度,比较得到最长的。 要进行两次循环,时间复杂度高。O(n^3); 改进中心扩展法: 字符串可能为奇数个或偶数个,奇数个时从一个中 阅读全文
posted @ 2017-07-12 19:37 hahahaf 阅读(142) 评论(0) 推荐(0) 编辑
摘要: find 函数主要实现的是在容器内查找指定的元素,查找成功返回一个指向指定元素的迭代器,查找失败返回end迭代器。 在数组中查找: int * p=find(first, end,val);//first 是容器的首迭代器,last是容器的末迭代器,val是要查找的元素。 在vector容器中查找: 阅读全文
posted @ 2017-07-11 20:26 hahahaf 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 实现要实现:构造,析构,拷贝构造,赋值的功能 1. 提供构造函数 string(), string(const string & str),string(const char * str), 2. 析构函数: ~ string() 3. 成员函数(重载赋值函数):string &operator=( 阅读全文
posted @ 2017-07-11 04:44 hahahaf 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 因为每个组合的字符串,至少要有3个index。 起点,中间拼接点,结点。所以可以将字符串分解为子字符串,判断子字符串是否存在。但是,后面字符串的存在必须要在前面字符串已经存在基础上判断。 substr (startpos, length); startpos是起始字符的符号,length为从 sta 阅读全文
posted @ 2017-07-11 00:07 hahahaf 阅读(412) 评论(0) 推荐(0) 编辑
摘要: 先介绍一下matlab与c混合编程 主要步骤: 使用c语言编写函数 利用mexFunction()函数创建C与matlab接口 从Matlab中编译函数 # include <mex.h>: 为了实现matlab与c混合编程的接口 这个代码是算法真正实现的地方。 然后创建接口。mex函数库中的mex 阅读全文
posted @ 2017-07-10 19:57 hahahaf 阅读(2153) 评论(0) 推荐(0) 编辑
摘要: 目的:为了保证包含的内容只被程序(include) 和编译了一次。判断预处理器常量是否已被定义。 预编译将所有头文件(#include"XXX.h")用头文件中的内容来替换,头文件中的内容都已经包含到需要他们的.cpp 中。最后生成.exe文件是由编译和链接两步完成的。编译时源代码生成obj 二进制 阅读全文
posted @ 2017-07-10 17:52 hahahaf 阅读(1501) 评论(0) 推荐(0) 编辑
摘要: my solution: wrong answer : because 2147483647*2 is -2 (int) , only 33bit can represent 2147483647--2147483647 signed 0-4294967295 unsigned then i cha 阅读全文
posted @ 2017-07-09 20:08 hahahaf 阅读(301) 评论(0) 推荐(0) 编辑