STL
飞翔在蓝天
这个作者很懒,什么都没留下…
展开
-
10.排序及相关操作
序号 功能 函数名称 说明 1 排序 Sort 以很好的平均效率排序 stable_sort 排序,并维持相同元素的原有顺序 partial_sort 将序列的前一部分排好序 partial_sort_copy 复制的同时将序列的前一部分原创 2017-03-22 09:29:49 · 392 阅读 · 0 评论 -
9.变异算法
1、copy #include #include using namespace std; int main() { int a[] = { 1, 2, 3, 4, 5 }; int b[5]; copy(a, a + 5, b); copy(a, a + 5, ostream_iterator(cout, " ")); cout << endl; copy(b, b + 5, o原创 2017-03-21 12:31:52 · 1927 阅读 · 0 评论 -
8.非变异算法
1、for_each #include #include #include using namespace std; class Print { private: int sum; int max; int min; int count; public: Print() :count(0), sum(0) {} int GetSum() { return sum; } int原创 2017-03-20 20:26:48 · 530 阅读 · 0 评论 -
5. string
#include #include using namespace std; int main() { string s = "do"; s.insert(0, "how "); s.append(" you"); s = s + " do?"; cout << s << endl; string s1 = "what's your name"; s1.replace(7, 4,原创 2016-10-04 17:53:29 · 319 阅读 · 0 评论 -
7.通用容器
1、bitset用法 #include #include #include using namespace std; int main() { bitsets1; cout << "初始化内存空间内容:" << s1.to_string() << endl; cout << s1.size() << " " << s1.count() << endl; s1.set(2,true);原创 2017-03-20 19:32:35 · 336 阅读 · 0 评论 -
6.函数对象 适配器的用法
#include #include #include #include using namespace std; int main() { vector v; for (int i = 0; i < 10; i++) { v.push_back(i); } //小于5的个数 int ncount = count_if(v.begin(), v.end(), bind2nd(le原创 2016-10-04 19:11:07 · 271 阅读 · 0 评论 -
3.迭代器
#include #include using namespace std; int main() { cout << "input data" << endl; istream_iteratora(cin); istream_iteratorb; while (1) { cout << *a << endl; a++; if (a == b) { break;原创 2017-03-19 20:28:17 · 266 阅读 · 0 评论 -
4.输入输出流
#include #include using namespace std; struct stu { char name[20]; int grade; }; int main() { char sz[80]; ifstream in; in.open("D:/project2013/STL/inputoutput/a.txt"); //ifstream in("D:\\proj原创 2016-10-03 19:58:36 · 249 阅读 · 0 评论 -
1.命名空间的使用
#include using namespace std; namespace mycompany { void fun() { printf("my"); } } namespace youcompany { void fun() { printf("your"); } } using namespace mycompany; int main() { fun(); c原创 2016-10-03 19:57:37 · 294 阅读 · 0 评论 -
stl:find _first_of与search用法
#include #include #include using namespace std; int main() { string str("i love you"); string str1 = "youf"; string::iterator ix = search(str.begin(), str.end(), str1.begin原创 2017-06-21 09:02:52 · 584 阅读 · 0 评论