上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 48 下一页
摘要: /****************************************************************************** * 用str.find_first_of(cstr, pos)查找str中的所有数字, * 算法:没查找到一个pos,从该pos的下一元素重新查找。 *********************************************... 阅读全文
posted @ 2012-12-18 22:36 helloweworld 阅读(346) 评论(0) 推荐(0) 编辑
摘要: sting s;记住典型的查找操作:s.find(args) s.find_fist_of(args)s.find_fist_not_of(args)还有3个逆序的查找操作,s.rfind(args)s.find_last_of(args)s.find_last_not_of(args)其中args可以为下面4个版本之一:c,poss2,poscp,poscp,pos,n例子:/****************************************************************************** * str.find(args)是完全匹配args中的字符串 阅读全文
posted @ 2012-12-18 22:29 helloweworld 阅读(293) 评论(0) 推荐(0) 编辑
摘要: cin输入流,空格隔开每个变量,回车接收,ctrl+z结束! /******************************************************************/#include <iostream>#include <vector>#include <string>#include <cctype>using namespace std;int main()... 阅读全文
posted @ 2012-12-16 14:45 helloweworld 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 《c专家编程》区别1:#define peach intusigned peach i; /*正确*/typedef int banana;unsigned banana i; /*错误*/区别2:#define int_ptr int *int_ptr chalk, cheese;宏扩展后相当于int * chalk,cheese;typedef int * int_ptr;int_ptr chalk, cheese;则表示int *chalk,*cheese;用typedef定义的类型能够保证声明中的变量为同一类型! 阅读全文
posted @ 2012-12-14 20:44 helloweworld 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 下面定义是对的:const int *a;int *const b; //b指向不可改int const *c; //c指向的变量的值不可改下面定义错误!const *int e;const在*的左边则指向的变量值只读,const在*的右边则指针指向只读,即“左定值,右定向”!注意:左定值右定向的参照物是* !!! 阅读全文
posted @ 2012-12-14 20:27 helloweworld 阅读(161) 评论(0) 推荐(0) 编辑
摘要: http://yantingting1219.blog.sohu.com/71850367.html cin 读取并忽略 非空白字符 之前所有的空白字符,然后读取字符直至再次遇到空白字符,读取终止。 /*sting对象接收流中字符*/#include <iostream>#include <string>using namespace std;int main(){ string str; cin... 阅读全文
posted @ 2012-12-13 21:40 helloweworld 阅读(392) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string>#include <cstring>using namespace std;int main(int argc, char** argv){ string str("hello world!,pun.test?good"); for (string::size_type i=0; i!=str.size(); i++) { ... 阅读全文
posted @ 2012-12-13 17:43 helloweworld 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 算法:只将 srcStr字符串中的 非标点字符 赋给destStr./*去掉字符串中的标点,字符指针操作*/#include <iostream>#include <ctype.h>#include <assert.h>using namespace std;char *delPunct(char *destStr, const char *srcStr){// assert(destStr... 阅读全文
posted @ 2012-12-12 16:01 helloweworld 阅读(457) 评论(0) 推荐(0) 编辑
摘要: 单词用空白键隔开。算法:每当遇到一个非空白字符,且该非空白字符的前面是空白字符,则单词数加1.该非空白符的前面是不是空白符用isword表示。注意不能用空白符的个数来表示单词的个数!#include <stdio.h>#include <string.h>int nword(char *s){ int nword = 0; int isword = 1; while (*s) { if (iss... 阅读全文
posted @ 2012-12-10 11:36 helloweworld 阅读(573) 评论(0) 推荐(0) 编辑
摘要: /*字符串中大写字母变成小写,其余字符不变*/#include <stdio.h>#include <string.h>char* mystrlwr(char *s){ char *scopy = s; while (*s) { if (*s >= 'A' && *s <= 'Z') { *s = *s + 'a' - 'A'; } s++; } return scopy;}char *... 阅读全文
posted @ 2012-12-10 10:46 helloweworld 阅读(2123) 评论(0) 推荐(0) 编辑
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 48 下一页