书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

随笔分类 -  C 字符串

后缀数组DC3算法实现
摘要:算法模板:View Code #define F(x) ((x)/3+((x)%3==1?0:tb))#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2)int wa[maxn],wb[maxn],wv[maxn],ws[maxn];int c0(int *r,int a,int b){return r[a]==r[b]&&r[a+1]==r[b+1]&&r[a+2]==r[b+2];}int c12(int k,int *r,int a,int b){if(k==2) return r[a]<r[b]||r[a]== 阅读全文

posted @ 2012-05-30 22:14 More study needed. 阅读(547) 评论(0) 推荐(0) 编辑

将数字字符串转化成整型数据
摘要:将数字字符串转化成整型数据我们将用到两个函数。1. c_str它的作用是将string对象转化成char*,为什么要这样做呢,这就要说起另外一个函数了。2.atoi (它是array to integer的缩写)它的作用是将数字字符串转化成整型数据。但是要注意atoi(const char * s), 这个是它的标准用法,如果是atoi(string s)这个就不行了。具体的用法是。View Code string str="-1234";int num = atoi(str.c_str());string str = "1234";int Num = 阅读全文

posted @ 2012-03-31 10:00 More study needed. 阅读(715) 评论(0) 推荐(0) 编辑

字符串啊字符串
摘要:No.1:用C++输入带空格的字符串, getchar()必不可少。cin>>n;getchar();while(n--) getline(cin, s);No.2:不可对string s, char *s, char s[100] 像这种的串一个字符一个字符的赋值, 会出现烫烫烫啊。但是可以对char s[100]={0}这样的字符赋值。 阅读全文

posted @ 2012-03-29 22:39 More study needed. 阅读(163) 评论(0) 推荐(0) 编辑

奇怪的字符数组初始化
摘要:今天做了一个题目,感觉字符数组的初始化有点奇怪,就亲自测试了一下,果不其然。确实很奇怪。这个就要和数组区分开了。一定不能将两者混淆了。下面给出测试的代码,并一一解析。View Code #include "iostream"#include "string"#include "cstring"using namespace std;#define size 10int main(){ char s1[size]="1", s2[size]={0}; for(int i=0; i<10; i++) cout&l 阅读全文

posted @ 2011-11-24 14:37 More study needed. 阅读(649) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

点击右上角即可分享
微信分享提示