• C++ STL进阶与补充(算法)


    STL算法主要由头文件alpgorithm,functional和numeric组成。Algothrim是所有STL头文件中最大的一个,范围涉及到比较、交换、查找、遍历、复制和修改等。Numeric体积很小,只包括在几个序列上进行简单数学运算的模板函数。Functional定义了一些模板类,用以声明函数对象。

    1、遍历算

    for_each

    遍历容器(熟练掌握)

    transform

    搬运容器到另一个容器中

    case 1: for_each

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void Print(int v)
    6. {
    7. cout << v << " ";
    8. }
    9. class Print2
    10. {
    11. public:
    12. void operator()(int val)
    13. {
    14. cout << val << " ";
    15. }
    16. };
    17. void test01()
    18. {
    19. vector<int> v1;
    20. for (int i = 0; i < 10; i++)
    21. {
    22. v1.push_back(i);
    23. }
    24. //利用普通函数实现遍历操作
    25. for_each(v1.begin(), v1.end(), Print);
    26. //仿函数进行操作
    27. for_each(v1.begin(), v1.end(), Print2());
    28. }
    29. int main()
    30. {
    31. test01();
    32. }

    case 2:tansform

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. class Transform
    6. {
    7. public:
    8. int operator()(int v)
    9. {
    10. return v+100; //在搬运过程中可以进行一些运算
    11. }
    12. };
    13. class Print
    14. {
    15. public:
    16. void operator()(int val)
    17. {
    18. cout << val << " ";
    19. }
    20. };
    21. void test01()
    22. {
    23. vector<int> v1;
    24. for (int i = 0; i < 10; i++)
    25. {
    26. v1.push_back(i);
    27. }
    28. vector<int> vTarget;
    29. vTarget.resize(v1.size()); //目标容器需要提前开辟好空间
    30. transform(v1.begin(),v1.end(),vTarget.begin(),Transform());
    31. for_each(vTarget.begin(), vTarget.end(), Print());
    32. cout << endl;
    33. }
    34. int main()
    35. {
    36. test01();
    37. }

    2、查找算法

    Find

    查找元素

    Find_if

    按条件查找元素

    Adjacent_find

    查找相邻重复元素

    Binary_search

    二分查找

    Count

    统计元素个数

    Count_if

    按条件统计元素个数

    2.1、find

    查找指定元素,找到返回指定元素的迭代器,找不到则返回结束迭代器end()。

    Find(iterator beg, iterator end, value);

    //beg 开始迭代器

    //end 结束迭代器

    //value 查找的元素

    利用find可以在容器中找到指定元素,返回值是迭代器。

    case 1:查找内置数据类型(查找等于5的数)

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void test01()
    6. {
    7. vector<int> v1;
    8. for (int i = 0; i < 10; i++)
    9. {
    10. v1.push_back(i);
    11. }
    12. vector<int>::iterator it=find(v1.begin(), v1.end(), 5);
    13. if (it == v1.end())
    14. {
    15. cout << "没有找到!" << endl;
    16. }
    17. else
    18. {
    19. cout << "找到了"<<*it << endl;
    20. }
    21. }
    22. int main()
    23. {
    24. test01();
    25. }

    case 2:查找自定义数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. class Person
    7. {
    8. public:
    9. Person(string name, int age)
    10. {
    11. this->m_name = name;
    12. this->m_age = age;
    13. }
    14. //重载==,让底层find知道如何对比person数据类型
    15. bool operator== (const Person& p)
    16. {
    17. if (this->m_name == p.m_name && this->m_age == p.m_age)
    18. {
    19. return true;
    20. }
    21. else
    22. return false;
    23. }
    24. string m_name;
    25. int m_age;
    26. };
    27. void test01()
    28. {
    29. vector<Person> v;
    30. Person p1("wxq",10);
    31. Person p2("szw", 20);
    32. Person p3("czt", 30);
    33. Person p4("dj", 40);
    34. v.push_back(p1);
    35. v.push_back(p2);
    36. v.push_back(p3);
    37. v.push_back(p4);
    38. //查找
    39. Person pp("szw", 20);
    40. vector<Person>::iterator it=find(v.begin(), v.end(), pp);
    41. if (it == v.end())
    42. {
    43. cout << "没有找到!" << endl;
    44. }
    45. else
    46. {
    47. cout << "找到了" << (*it).m_name << ", age is " << (*it).m_age << endl;
    48. }
    49. }
    50. int main()
    51. {
    52. test01();
    53. }

    2.1、find_if

    按条件查找元素。

    Find_if(iterator beg, iterator end, _Pred);

    //按谓词查找,返回指定位置的迭代器,找不到则返回结束迭代器。

    //beg 开始迭代器

    //end 结束迭代器

    //_Pred 函数或谓词(返回bool类型的仿函数)

    case 1:查找内置数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. class Greater
    7. {
    8. public:
    9. bool operator()(int val)
    10. {
    11. return val > 5;
    12. }
    13. };
    14. void test01()
    15. {
    16. vector<int> v;
    17. for (int i = 0; i < 10; i++)
    18. {
    19. v.push_back(i);
    20. }
    21. vector<int>::iterator it =find_if(v.begin(),v.end(),Greater());
    22. if (it == v.end())
    23. {
    24. cout << "没有找到!" << endl;
    25. }
    26. else
    27. {
    28. cout << "找到了大于5的数字为" << *it << endl;
    29. }
    30. }
    31. int main()
    32. {
    33. test01();
    34. }

    case 2:查找自定义数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. class Person
    7. {
    8. public:
    9. Person(string name, int age)
    10. {
    11. this->m_name = name;
    12. this->m_age = age;
    13. }
    14. string m_name;
    15. int m_age;
    16. };
    17. class Greater20
    18. {
    19. public:
    20. bool operator()(Person& p)
    21. {
    22. return p.m_age > 20;
    23. }
    24. };
    25. void test01()
    26. {
    27. vector<Person> v;
    28. Person p1("wxq", 10);
    29. Person p2("szw", 20);
    30. Person p3("czt", 30);
    31. Person p4("dj", 40);
    32. v.push_back(p1);
    33. v.push_back(p2);
    34. v.push_back(p3);
    35. v.push_back(p4);
    36. //查找年龄大于20的人
    37. vector<Person>::iterator it =find_if(v.begin(),v.end(),Greater20());
    38. if (it == v.end())
    39. {
    40. cout << "没有找到!" << endl;
    41. }
    42. else
    43. {
    44. cout << "找到了大于20的人为:" << (*it).m_name << endl;
    45. }
    46. }
    47. int main()
    48. {
    49. test01();
    50. }

    2.3、adjacent_find

    查找相邻重复元素,返回相邻元素的第一个位置的迭代器。

    Adjacent_find(iterator beg, iterator end);

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. void test01()
    7. {
    8. vector<int> v;
    9. v.push_back(0);
    10. v.push_back(2);
    11. v.push_back(0);
    12. v.push_back(1);
    13. v.push_back(1);
    14. v.push_back(3);
    15. vector<int>::iterator pos=adjacent_find(v.begin(), v.end());
    16. if (pos == v.end())
    17. {
    18. cout << "未找到重复元素!" << endl;
    19. }
    20. else
    21. {
    22. cout << *pos << "重复!" << endl;
    23. }
    24. }
    25. int main()
    26. {
    27. test01();
    28. }

    2.4、binary_search

    Bool binary_search(iterator beg, iterator end, value);

    //二分查找无法查找无序序列,且仅能返回true或false。

    容器必须是有序序列。如果是无序的序列,则结果是未知的。

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. void test01()
    7. {
    8. vector<int> v;
    9. v.push_back(0);
    10. v.push_back(1);
    11. v.push_back(3);
    12. v.push_back(4);
    13. v.push_back(5);
    14. v.push_back(6);
    15. bool result = binary_search(v.begin(), v.end(), 5);
    16. if (!result)
    17. {
    18. cout << "未找到重复元素!" << endl;
    19. }
    20. else
    21. {
    22. cout << "找到了元素!" << endl;
    23. }
    24. }
    25. int main()
    26. {
    27. test01();
    28. }

    2.5、count

    统计元素个数,返回一个int类型。对于自定义数据类型,需要重载==号。

    Count(iterator beg, iterator end, value);

    case 1:统计内置数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. void test01()
    7. {
    8. vector<int> v;
    9. v.push_back(10);
    10. v.push_back(10);
    11. v.push_back(20);
    12. v.push_back(30);
    13. v.push_back(40);
    14. v.push_back(40);
    15. int num = count(v.begin(), v.end(), 40);
    16. cout << num;
    17. }
    18. int main()
    19. {
    20. test01();
    21. }

    case 2:统计自定义数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. class Person
    7. {
    8. public:
    9. Person(string name, int age)
    10. {
    11. this->m_name = name;
    12. this->m_age = age;
    13. }
    14. bool operator==(const Person& p)
    15. {
    16. if (this->m_age == p.m_age)
    17. {
    18. return true;
    19. }
    20. else
    21. return false;
    22. }
    23. string m_name;
    24. int m_age;
    25. };
    26. void test01()
    27. {
    28. vector<Person> v;
    29. Person p1("wxq", 10);
    30. Person p2("szw", 20);
    31. Person p3("czt", 30);
    32. Person p4("dj", 20);
    33. v.push_back(p1);
    34. v.push_back(p2);
    35. v.push_back(p3);
    36. v.push_back(p4);
    37. Person pp("xl", 20); //查找和XL相同岁数的人有几个
    38. int num = count(v.begin(), v.end(), pp);
    39. cout << "相同岁数的人有" << num << "个。" << endl;
    40. }
    41. int main()
    42. {
    43. test01();
    44. }

    2.6、count_if

    按照条件统计元素个数。条件由谓词决定。谓词通过仿函数设置。

    Count_if(iterator beg, iterator end, _Pred);

    case 1:内置数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. class Greater20
    6. {
    7. public:
    8. bool operator()(int v)
    9. {
    10. return v > 20;
    11. }
    12. };
    13. void test01()
    14. {
    15. vector<int> v;
    16. v.push_back(10);
    17. v.push_back(40);
    18. v.push_back(30);
    19. v.push_back(20);
    20. v.push_back(40);
    21. v.push_back(20);
    22. int num=count_if(v.begin(), v.end(),Greater20());
    23. cout << "大于20的元素个数为:" << num << endl;
    24. }
    25. int main()
    26. {
    27. test01();
    28. }

    case 2:自定义数据类型

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include"string"
    5. using namespace std;
    6. class Person
    7. {
    8. public:
    9. Person(string name, int age)
    10. {
    11. this->m_name = name;
    12. this->m_age = age;
    13. }
    14. string m_name;
    15. int m_age;
    16. };
    17. class Greater20
    18. {
    19. public:
    20. bool operator()(const Person& p)
    21. {
    22. return p.m_age > 20;
    23. }
    24. };
    25. void test01()
    26. {
    27. vector<Person> v;
    28. Person p1("wxq", 10);
    29. Person p2("szw", 20);
    30. Person p3("czt", 30);
    31. Person p4("dj", 20);
    32. v.push_back(p1);
    33. v.push_back(p2);
    34. v.push_back(p3);
    35. v.push_back(p4);
    36. int num = count_if(v.begin(), v.end(), Greater20());
    37. cout << "大于20岁的人数为" << num << "个。" << endl;
    38. }
    39. int main()
    40. {
    41. test01();
    42. }

    2.7、sort、random_shuffle、merge和reverse

    Sort

    对容器内元素进行排序

    Random_shuffle

    指定范围内元素随机调整次序(洗牌)

    Merge

    容器元素合并,并存储到另一容器中

    reverse

    反转指定范围的元素

    Sort(iterator beg, iterator end, _Pred);

    //_Pred谓词,改变排序规则

    Random_shuffle(iterator beg, iterator end);

    Merge(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    //合并算法(两个容器必须有序(同为升序或降序),合并之后依然有序,合并后不会消除相同元素)

    //dest目标容器的开始迭代器

    Reverse(interator beg, iterator end);

    case 1:排序算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include<functional>
    5. using namespace std;
    6. void Print(int val)
    7. {
    8. cout << val << " ";
    9. }
    10. void test01()
    11. {
    12. vector<int> v;
    13. v.push_back(10);
    14. v.push_back(20);
    15. v.push_back(5);
    16. v.push_back(1);
    17. sort(v.begin(), v.end());
    18. for_each(v.begin(), v.end(), Print);
    19. cout << endl;
    20. //降序排列
    21. sort(v.begin(),v.end(),greater<int>());
    22. for_each(v.begin(), v.end(), Print);
    23. cout << endl;
    24. }
    25. int main()
    26. {
    27. test01();
    28. }

    case 2:洗牌算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. #include<time.h>
    5. using namespace std;
    6. void Print(int val)
    7. {
    8. cout << val << " ";
    9. }
    10. void test01()
    11. {
    12. srand((unsigned int)time(NULL)); //用系统时间生成种子作为真正的随机数
    13. vector<int> v;
    14. v.push_back(1);
    15. v.push_back(2);
    16. v.push_back(5);
    17. v.push_back(3);
    18. //升序排列
    19. sort(v.begin(), v.end());
    20. for_each(v.begin(), v.end(), Print);
    21. cout << endl;
    22. //洗牌1次
    23. random_shuffle(v.begin(),v.end());
    24. for_each(v.begin(), v.end(), Print);
    25. cout << endl;
    26. //洗牌2次
    27. random_shuffle(v.begin(), v.end());
    28. for_each(v.begin(), v.end(), Print);
    29. cout << endl;
    30. }
    31. int main()
    32. {
    33. test01();
    34. }

    case 3:合并算法(两个容器必须有序,合并之后依然有序)

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void Print(int val)
    6. {
    7. cout << val << " ";
    8. }
    9. void test01()
    10. {
    11. vector<int> v1;
    12. vector<int> v2;
    13. for (int i = 0; i < 10; i++)
    14. {
    15. v1.push_back(i);
    16. v2.push_back(i + 1);
    17. }
    18. //目标容器,需要提前分配内存
    19. vector<int> Target;
    20. Target.resize(v1.size() + v2.size());
    21. merge(v1.begin(), v1.end(), v2.begin(), v2.end(), Target.begin());
    22. for_each(Target.begin(), Target.end(), Print);
    23. cout << endl;
    24. }
    25. int main()
    26. {
    27. test01();
    28. }

    case 4:反转算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void Print(int val)
    6. {
    7. cout << val << " ";
    8. }
    9. void test01()
    10. {
    11. vector<int> v1;
    12. for (int i = 0; i < 10; i++)
    13. {
    14. v1.push_back(i);
    15. }
    16. for_each(v1.begin(), v1.end(), Print);
    17. cout << endl;
    18. //反转后的代码
    19. reverse(v1.begin(), v1.end());
    20. for_each(v1.begin(), v1.end(), Print);
    21. cout << endl;
    22. }
    23. int main()
    24. {
    25. test01();
    26. }

    3、拷贝和替换算法

    Copy

    容器内指定范围的元素拷贝到另一容器中

    Replace

    将容器内指定范围内的元素修改为新元素

    Replace_if

    容器内指定范围内满足条件的元素替换为新元素

    swap

    互换两个容器的元素

    Copy(iterator beg, iterator end, iterator dest);

    //dest目标起始迭代器

    replace(iterator beg, iterator end,oldvalue, newvalue);

    //将旧值替换为新值

    //注意是将其中元素均为oldvalue的值替换为newvalue

    Replace_if(iterator beg, iterator end, _Pred, newvalue);

    //_Pred谓词,即条件

    Swap(container c1, container c2);

    //同种类型的容器才可以互换

    case 1:copy算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void Print(int val)
    6. {
    7. cout << val << " ";
    8. }
    9. void test01()
    10. {
    11. vector<int> v1;
    12. for (int i = 0; i < 10; i++)
    13. {
    14. v1.push_back(i);
    15. }
    16. vector<int> v2;
    17. v2.resize(v1.size());//分配内存空间
    18. copy(v1.begin(),v1.end(),v2.begin());
    19. for_each(v2.begin(), v2.end(), Print);
    20. cout << endl;
    21. }
    22. int main()
    23. {
    24. test01();
    25. }

    case 2:replace算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. class MyPrint
    6. {
    7. public:
    8. void operator()(int val)
    9. {
    10. cout << val << " ";
    11. }
    12. };
    13. void test01()
    14. {
    15. vector<int> v1;
    16. for (int i = 0; i < 10; i++)
    17. {
    18. v1.push_back(i);
    19. }
    20. cout << "替换前为:" << endl;
    21. for_each(v1.begin(), v1.end(), MyPrint());
    22. cout << endl;
    23. replace(v1.begin(), v1.end(), 5, 50);
    24. cout << "5替换为50:" << endl;
    25. for_each(v1.begin(), v1.end(), MyPrint());
    26. cout << endl;
    27. }
    28. int main()
    29. {
    30. test01();
    31. }

    case 3:replace_if算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. class MyPrint
    6. {
    7. public:
    8. void operator()(int val)
    9. {
    10. cout << val << " ";
    11. }
    12. };
    13. class Greater5
    14. {
    15. public:
    16. bool operator()(int val)
    17. {
    18. return val > 5;
    19. }
    20. };
    21. void test01()
    22. {
    23. vector<int> v1;
    24. for (int i = 0; i < 10; i++)
    25. {
    26. v1.push_back(i);
    27. }
    28. cout << "替换前为:" << endl;
    29. for_each(v1.begin(), v1.end(), MyPrint()); //使用仿函数打印
    30. cout << endl;
    31. //将大于5的替换为9
    32. replace_if(v1.begin(), v1.end(), Greater5(), 9);
    33. cout << "替换前后:" << endl;
    34. for_each(v1.begin(), v1.end(), MyPrint()); //使用仿函数打印
    35. cout << endl;
    36. }
    37. int main()
    38. {
    39. test01();
    40. }

    case 4:swap算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. class MyPrint
    6. {
    7. public:
    8. void operator()(int val)
    9. {
    10. cout << val << " ";
    11. }
    12. };
    13. void test01()
    14. {
    15. vector<int> v1;
    16. vector<int> v2;
    17. for (int i = 0; i < 10; i++)
    18. {
    19. v1.push_back(i);
    20. v2.push_back(i+100);
    21. }
    22. cout << "交换前为:" << endl;
    23. for_each(v1.begin(), v1.end(), MyPrint()); //使用仿函数打印
    24. cout << endl;
    25. for_each(v2.begin(), v2.end(), MyPrint());
    26. cout << endl;
    27. //交换v1和v2
    28. swap(v1, v2);
    29. cout << "交换后为:" << endl;
    30. for_each(v1.begin(), v1.end(), MyPrint());
    31. cout << endl;
    32. for_each(v2.begin(), v2.end(), MyPrint());
    33. cout << endl;
    34. }
    35. int main()
    36. {
    37. test01();
    38. }

    4、算术生成算法

    算术生成算法属于小型算法,使用时需要包含头文件#include<numeric>

    Accumulate

    计算容器元素累计总和

    Fill

    向容器中添加元素

    Accumulate(iterator beg, iterator end, value)

    //value起始值,是一个起始的累加值

    fill(iterator beg, iterator end, value);

    //一般用于后期,重新填充

    case 1:累加求和

    1. #include<iostream>
    2. #include<vector>
    3. #include<numeric>
    4. using namespace std;
    5. void test01()
    6. {
    7. vector<int> v;
    8. for (int i = 0; i <= 100; i++)
    9. {
    10. v.push_back(i);
    11. }
    12. int total=accumulate(v.begin(), v.end(), 0);//0表示起始累加值为0
    13. cout << "total=" << total << endl;
    14. }
    15. int main()
    16. {
    17. test01();
    18. }

    case 2:填充算法

    1. #include<iostream>
    2. #include<vector>
    3. #include<numeric>
    4. #include<algorithm>
    5. using namespace std;
    6. void Print(int val)
    7. {
    8. cout << val << " ";
    9. }
    10. void test01()
    11. {
    12. vector<int> v;
    13. v.resize(10);
    14. //重新填充
    15. fill(v.begin(), v.end(), 100);
    16. for_each(v.begin(), v.end(), Print);
    17. cout << endl;
    18. }
    19. int main()
    20. {
    21. test01();
    22. }

    5、集合算法

    Set_intersection

    求两个容器的交集

    Set_union

    求两个容器的并集

    Set_difference

    求两个容器的差集

    Set_intersection(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    //会返回一个迭代器,指向交集最后位置

    //dest目标容器的开始迭代器

    //原容器必须为有序序列

    Set_union(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    //dest目标容器的开始迭代器

    //原容器必须为有序序列

    //会返回一个迭代器,指向交集最后位置

    case 1:求交集

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void Print(int val)
    6. {
    7. cout << val << " ";
    8. }
    9. void test01()
    10. {
    11. vector<int> v1;
    12. vector<int> v2;
    13. vector<int> Target;
    14. for (int i = 0; i < 10; i++)
    15. {
    16. v1.push_back(i);
    17. v2.push_back(i + 5);
    18. }
    19. //目标容器需要提前开辟空间
    20. //最特殊的情况为:大容器包含小容器,取小容器的空间即可
    21. Target.resize(min(v1.size(),v2.size()));
    22. vector<int>::iterator itEnd = set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), Target.begin());
    23. for_each(Target.begin(), itEnd, Print); //开辟的容量可能会大,所以用返回的结束迭代器
    24. cout << endl;
    25. }
    26. int main()
    27. {
    28. test01();
    29. }

    case 2:求并集

    1. #include<iostream>
    2. #include<vector>
    3. #include<algorithm>
    4. using namespace std;
    5. void Print(int val)
    6. {
    7. cout << val << " ";
    8. }
    9. void test01()
    10. {
    11. vector<int> v1;
    12. vector<int> v2;
    13. vector<int> Target;
    14. for (int i = 0; i < 10; i++)
    15. {
    16. v1.push_back(i);
    17. v2.push_back(i + 5);
    18. }
    19. //目标容器需要提前开辟空间
    20. //最特殊的情况为:两个容器空间之和
    21. Target.resize(v1.size()+v2.size());
    22. vector<int>::iterator itEnd = set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), Target.begin());
    23. for_each(Target.begin(), itEnd, Print); //开辟的容量可能会大,所以用返回的结束迭代器
    24. cout << endl;
    25. }
    26. int main()
    27. {
    28. test01();
    29. }
  • 相关阅读:
    超详细SVG实战——徒手画pipeline,带你玩转SVG
    一次性生物反应器袋充气压力更安全、精密和快速的控制方法
    c++inline关键字详解
    C_C语言中的基本类型转换规律/格式化输入输出控制符(scanf/printf)
    【 java 常用类】你不知道的String
    CANoe-vTESTstudio之State Diagram编辑器(元素介绍)
    docker入门加实战—docker数据卷
    Qt 之自定义控件(开关按钮)
    如何通俗理解海涅定理
    ElasticSearch从入门到精通:基础知识
  • 原文地址:https://blog.csdn.net/Lao_tan/article/details/125479151