码迷,mamicode.com
首页 >  
搜索关键字:strlen    ( 2530个结果
KMP - 简单应用
#include#includechar s1[1000005],s2[1000005];int next[1000005];void get_next(char s[1000005]){ int i = 0; int len = strlen(s); next[0] = -1;...
分类:其他好文   时间:2014-08-14 16:37:38    阅读次数:174
串匹配
//BF 算法int BFmatch(char *s,char *p){ int i,j; i = 0; while(i<strlen(s)) { j = 0; while(s[i] == p[j] && j<strlen(p)) {...
分类:其他好文   时间:2014-08-14 16:11:58    阅读次数:190
string 中的 length函数 和size函数 返回值问题
string 中的 length函数 和 size函数 的返回值( 还有 char [ ] 中 测量字符串的strlen 函数)应该是 unsigned int 类型的不可以 和 -1 比较。应尽量避免 unsigned int 类型 和 int类型 数据 的比较 。当unsigned int 类型...
分类:其他好文   时间:2014-08-13 22:02:37    阅读次数:227
倒置字符串函数reverse
倒置字符串函数reverse:用于倒置字符串s中的各个字符的位置,如原来字符串中如果初始值为123456,则通过reverse函数可将其倒置为654321,程序如下:#include#includevoid reverse(char s[]){ int c,j,i;for(i=0,j=strlen(...
分类:其他好文   时间:2014-08-13 14:24:16    阅读次数:201
004字符串去重 (keep it up)
设计算法并写出代码移除字符串中重复的字符,不能使用额外的缓存空间。注意: 可以使用额外的一个或两个变量,但不允许额外再开一个数组拷贝。 简单题直接上代码: #include #include void remove_duplicate(char vStr[]) { int Len = strlen(vStr); if (!Len) { printf("the stri...
分类:其他好文   时间:2014-08-13 01:11:05    阅读次数:252
我要好offer之 str/mem系列手写代码
1. str*系列手写代码a. 一定要注意末尾'\0'的处理,切记切记b. 一定要对输入做有效性判断,多用断言就是了int Strlen(const char* str) { assert(str != NULL); const char* tmp = str; while (*t...
分类:其他好文   时间:2014-08-12 21:33:04    阅读次数:265
PHP中使用XMLRPC
PHP中简单使用XMLRPC,服务器端和客户端都为PHP代码实现。服务器端:xmlrpc_s.phpgetParam(0)); //返回结果 if(strlen($words) > 0) { return new xmlrpcresp( new xmlrpcval('Server say:...
分类:Web程序   时间:2014-08-12 18:50:24    阅读次数:178
题目558-一二三-nyoj20140812
#include #include int main(){ int n,l; char a[10]; scanf("%d",&n); getchar(); while(n--) { gets(a); l=strlen(a); if(l==5) printf("3\n"); else if(l==3)...
分类:其他好文   时间:2014-08-12 18:04:14    阅读次数:195
使用递归求解1 到最大的n位数
用求排列方法: 代码: #include using namespace std; //使用递归求解1 到最大的n位数 void print(char * number){ bool isBegin = true; int length = strlen(number); for(int i = 0; i < length; i ++){ if(isBegin && numb...
分类:其他好文   时间:2014-08-12 13:38:34    阅读次数:173
strcpy,strncpy, strlen, strcmp strcat函数实现
#include #include char* strcpy(char* strDest, const char* strSrc) { assert((strDest != NULL) && (strSrc != NULL)); char* address = strDest; while((*strDest++ = *strSrc++) != '\0') NULL; r...
分类:其他好文   时间:2014-08-12 10:21:03    阅读次数:198
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!