随笔分类 -  c++

摘要:string (1) string& assign (const string& str); substring (2) string& assign (const string& str, size_t subpos, size_t sublen); c-string (3) string& as 阅读全文
posted @ 2019-12-23 10:14 MoonXu 阅读(489) 评论(0) 推荐(0) 编辑
摘要:string (1) string& append (const string& str); substring (2) string& append (const string& str, size_t subpos, size_t sublen); c-string (3) string& ap 阅读全文
posted @ 2019-12-23 09:53 MoonXu 阅读(550) 评论(0) 推荐(0) 编辑
摘要:string (1) string& replace (size_t pos, size_t len, const string& str); string& replace (const_iterator i1, const_iterator i2, const string& str); sub 阅读全文
posted @ 2019-12-20 10:27 MoonXu 阅读(597) 评论(0) 推荐(0) 编辑
摘要:string substr (size_t pos = 0, size_t len = npos) const; #include <iostream> #include <string>using namespace std;int main(){ string s1 = "i love lyy, 阅读全文
posted @ 2019-12-19 19:03 MoonXu 阅读(440) 评论(0) 推荐(0) 编辑
摘要:string (1) size_t rfind (const string& str, size_t pos = npos) const noexcept; c-string (2) size_t rfind (const char* s, size_t pos = npos) const; buf 阅读全文
posted @ 2019-12-19 18:35 MoonXu 阅读(403) 评论(0) 推荐(0) 编辑
摘要:string (1) size_t find (const string& str, size_t pos = 0) const noexcept; c-string (2) size_t find (const char* s, size_t pos = 0) const; buffer (3) 阅读全文
posted @ 2019-12-19 18:05 MoonXu 阅读(371) 评论(0) 推荐(0) 编辑
摘要:1. compare string (1) 4int compare (const string& str) const noexcept; substrings (2) int compare (size_t pos, size_t len, const string& str) const; i 阅读全文
posted @ 2019-12-19 17:39 MoonXu 阅读(483) 评论(0) 推荐(0) 编辑
摘要:添加 -lpthread CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/tools/boost/includeexport CPLUS_INCLUDE_PATH LIBRARY_PATH=$LIBRARY_PATH:/tools/boost/libexport LI 阅读全文
posted @ 2019-07-26 15:10 MoonXu 阅读(274) 评论(0) 推荐(0) 编辑
摘要:multiset容器,与set容器相似,但是multiset容器中的元素可以重复。 另外,他也是自动排序的,容器内部的值不能随便修改,因为有顺序的。 mset.insert(i);//插入 可以再次插入 mset.erase(iiit);//删除 阅读全文
posted @ 2019-07-16 16:12 MoonXu 阅读(225) 评论(0) 推荐(0) 编辑
摘要:C++的set容器,其中包含的元素是唯一的,而且是有序的。 C++的set容器,是按照顺序插入的,不能在指定位置插入。 C++的set容器,其结构是红黑二叉树,插入数据的效率比vector快 基础类型数据,如果插入的是重复的元素,则插入失败,返回值是一个pair类型 pair类型类似于swift语言 阅读全文
posted @ 2019-07-16 15:21 MoonXu 阅读(229) 评论(0) 推荐(0) 编辑
摘要:排序队列 priority_queue<int>默认定义int类型的最大值队列 首元素最大,递减 priority_queue<int, vector<int>, less<int>>定义int型的最大值优先队列 首元素最大,递减 priority_queue<int, vector<int>, g 阅读全文
posted @ 2019-07-16 14:41 MoonXu 阅读(114) 评论(0) 推荐(0) 编辑
摘要:q1.push(4)//入队列 q1.empty()//空 q1.front()//首元素 q1.back()//为元素 q1.size()//尺寸 阅读全文
posted @ 2019-07-16 13:33 MoonXu 阅读(139) 评论(0) 推荐(0) 编辑
摘要:ss.push(1);//入栈 ss.pop();//出栈 ss.top()//栈顶元素 ss.size()//栈的尺寸 阅读全文
posted @ 2019-07-16 13:15 MoonXu 阅读(112) 评论(0) 推荐(0) 编辑
摘要://4种遍历方法 for (int i = 0; i < v1.size(); i++) { cout << v1[i] << " "; } for (int i = 0; i < v1.size(); i++) { cout << v1.at(i) << " "; } for (vector<in 阅读全文
posted @ 2019-07-16 11:44 MoonXu 阅读(140) 评论(0) 推荐(0) 编辑
摘要:transform(first,last,result,op);//first是容器的首迭代器,last为容器的末迭代器,result为存放结果的容器,op为要进行操作的 阅读全文
posted @ 2019-07-16 11:21 MoonXu 阅读(198) 评论(0) 推荐(0) 编辑
摘要:at()//遍历 length()//长度 begin() end()//迭代器 str.copy(buf, 7, 4) //拷贝str下标为4开始的7的字符 c_str()//c风格字符串 s1.append(s2);//拼接 s5.find("hello", 5);//从下标5开始查找首次出现h 阅读全文
posted @ 2019-07-16 11:20 MoonXu 阅读(255) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <string> using namespace std;int main(int argc, const char * argv[]) { //string str("abcdefg"); string str = "abcdefg"; // 阅读全文
posted @ 2019-07-16 10:30 MoonXu 阅读(4186) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> using namespace std; int main(int argc, const char * argv[]) { //通过const char * 初始化 string s1 = "aaaa"; //构造函数初始化 string s2("bbbbb 阅读全文
posted @ 2019-07-16 10:26 MoonXu 阅读(4154) 评论(0) 推荐(0) 编辑
摘要:unsigned cnt = 10; string bad[cnt];//错误cnt不是常量表达式 constexpr unsigned cnt = 10; string bad[cnt];//正确 阅读全文
posted @ 2019-07-15 10:26 MoonXu 阅读(118) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <string>using namespace std;using std::_Adjust_manually_vector_aligned;int main(){ vector<string> str; st 阅读全文
posted @ 2019-07-15 10:08 MoonXu 阅读(305) 评论(0) 推荐(0) 编辑

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