STL-常用算法

news2024/9/28 5:26:23

概述:

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

一、常用遍历算法

算法简介:

  • for_each  //遍历容器
  • transform  //搬运容器到另一个容器中

(一)for_each

功能描述:

  • 实现遍历容器

函数原型:

  • for_each(iterator beg,iterator end ,_func);

//遍历算法 遍历容器元素

//beg 开始迭代器

//end 结束迭代器

//_func 函数或者函数对象

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
//普通函数
void print01(int val){
    cout<<val<<" ";
}
//仿函数
class print02{
    public:
        void operator()(const int& val)const{
            cout<<val<<" ";
        }
};

//常用遍历算法 for_each()
void test01(){
    vector<int> v;
    for(int i=0;i<10;i++){
        v.push_back(i);
    }
    for_each(v.begin(),v.end(),print01);
    cout<<endl;
    for_each(v.begin(),v.end(),print02());
    cout<<endl;
}

int main(){
    test01();
    system("pause");
    return 0;
}

(二)transfrom

功能描述:

  • 搬运容器到另一个容器中

函数原型:

  • transfrom(iterator beg1,iterator end,iterator begin2,_func);

//beg1源容器开始迭代器

//end 源容器结束迭代器

/beg2 目标容器开始迭代器

//_func函数或者函数对象

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
//transform()函数的使用
class Transform{
    public:
        int operator()(const int& a){
            return a+100; //还可以在仿函数中加一些逻辑运算
        }
};
class MyPrint{
    public:
        void operator()(const int& a){
            cout<<a<<" ";
        }
};
void test01(){
    vector<int> v;
    for(int i=0;i<10;i++){
        v.push_back(i);
    }
    vector<int> v2;
    v2.resize(v.size()); //transform前必须扩容
    transform(v.begin(),v.end(),v2.begin(),Transform());
    for_each(v2.begin(),v2.end(),MyPrint());

}

int main(){
    test01();
    system("pause");
    return 0;
}

二、常用的查找算法

算法简介:

  • find    //查找元素
  • find_if  //按条件查找元素
  • adjancent_find  //查找相邻重复元素
  • binary_serach  //二分查找法
  • count  //统计元素个数
  • count_if  //按条件统计个数

(一)find

功能描述:

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

函数原型:

  • find(iterator beg,iterator end,value);

//按值查找元素,找到返回制定位置的迭代器,找不到返回结束迭代器位置

//beg 开始迭代器

//end 结束迭代器

//value 查找的元素

#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
//常用的查找算法
//find
//查找内置的数据类型
void test01(){
    vector<int>v;
    for(int i=0;i<10;i++){
        v.push_back(i);
    }
    //查找容器中是否有5这个元素
    vector<int>::iterator it=find(v.begin(),v.end(),5);
    if(it == v.end()){
        cout<<"没有找到"<<endl;
    }else{
        cout<<"找到了"<<endl;
    }

}
class Person{
public:
    Person(string name,int age){
        this->m_name=name;
        this->m_age=age;
    }
    //重载== 底层find知道如何对比Person数据类型
    bool operator==(const Person& p){
        if(this->m_name == p.m_name && this->m_age == p.m_age){
            return true;
        }else{
            return false;
        }
    }
    string m_name;
    int m_age;
};
void test02(){
    vector<Person> v;
    //创建数据
    Person p1("aaa",10);
    Person p2("bbb",20);
    Person p3("ccc",30);
    v.push_back(p1);    
    v.push_back(p2);
    v.push_back(p3);
    vector<Person>::iterator it =find(v.begin(),v.end(),p3);
    if(it == v.end()){
        cout<<"没有找到"<<endl;
    }else{
        cout<<"找到了"<<endl;
        cout<<"姓名:"<<it->m_name<<" 年龄:"<<it->m_age<<endl;
    }
}
//查找自定义的数据类型
int main(){
    test01();
    test02();
    system("pause");
    return 0;
}

(二)find_if

功能描述:

  • 按条件查找元素

函数原型:

  • find_if(iterator beg,iterator end ,_Pred);

//按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置

//beg 开始迭代器

//end 结束迭代器

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

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
//常用的查找算法 find_if()
//1.查找内置数据类型
class GreaterFive
{
public:
    bool operator()(const int& val) const{
        return val>5;
    }
};
void test01(){
    vector<int> v;
    for(int i=0;i<10;i++){
        v.push_back(i);
    }
vector<int>::iterator it = find_if(v.begin(),v.end(),GreaterFive()); 
if(it == v.end()){
    cout<<"没有找到"<<endl;
}else{
    cout<<"找到了"<<*it<<endl;
}
}
//2.查找自定义数类型
class Person{
public:
    Person(string name,int age)
    {
        this->m_name = name;
        this->m_age = age;
    }
    string m_name;
    int m_age;
};
class MyFind{
public:
    bool operator()(const Person& p)const{
        return p.m_age >18;
    }
};
void test02(){
    vector<Person> v;
    Person p1("Tom",19);
    Person p2("Jerry",20);
    Person p3("Mary",17);
    v.push_back(p1);
    v.push_back(p2);
    v.push_back(p3);
    vector<Person>::iterator it = find_if(v.begin(),v.end(),MyFind()); 
if(it == v.end()){
    cout<<"没有找到"<<endl;
}else{
    cout<<"找到了"<<(*it).m_name<<endl;
}

}
int main(){
    test01();
    test02();
    system("pause");
    return 0;
}

 

(三)adjacent_find

功能描述:

  • 查找相邻重复元素

函数原型:

  • adjacent_find(iterator beg,iterator end);

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

//beg开始迭代器

//end结束迭代器

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//常用查找算法 adjacent_find();
void test01(){
    vector<int>v;
    v.push_back(0);
    v.push_back(2);
    v.push_back(3);
    v.push_back(1);
    v.push_back(4);
    v.push_back(3);
    v.push_back(3);
vector<int>::iterator pos = adjacent_find(v.begin(),v.end());
if (pos !=v.end()){
    cout<<"找到相邻重复元素" <<*pos <<endl;
    }else{
        cout<<"没有找到相邻重复元素"<<endl;
    }
}
int main(){
    test01();
    system("pause");
    return 0;
}

(四)binary_search

功能描述:

  • 查找指定元素是否存在

函数原型:

  • bool binary_search(iterator beg,iterator end ,value);

//查找指定的元素,查到返回true 否则返回false

//注意:在无序序列中不可用

//beg开始迭代器

//end 结束迭代器

//value 查找到元素

#include <iostream>
using namespace std;
#include<vector>
#include<algorithm>
//常用查找算法 binary_search
void test01(){
    vector<int> v;
    for(int i=0;i<10;i++){
        v.push_back(i);
    }
bool flag= binary_search(v.begin(),v.end(),9);
if(flag){
    cout<<"9 is in the vector"<<endl;
}else{
    cout<<"9 is not in the vector"<<endl;
}
}

int main(){
    test01();    
    system("pause");
    return 0;
}

(五)count

功能描述:

  • 统计元素个数

函数原型:

  • count (iterator beg,iterator end ,value);

//统计元素出现的次数

//beg开始迭代器

//end结束迭代器

//value统计的元素

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//常用查找算法count
//1.统计内置数据类型
void test01(){
    vector<int> v;
    v.push_back(10);
    v.push_back(40);
    v.push_back(30);
    v.push_back(40);
    v.push_back(20);
    v.push_back(40);
    v.push_back(40);
    int num = count(v.begin(),v.end(),40);
    cout<<"num of 40 is "<<num<<endl;
}

//2.统计自定义数据类型
class Person{
public:
    Person(string name,int age){
        this->m_name=name;
        this->m_age=age;
    }
     bool operator == (const Person& p) const{
        if(this->m_age==p.m_age){
            return true;
        }
        return false;
     }
string m_name;
int m_age;

};
void test02(){
    vector<Person> v;
    Person p1("刘备",20);
    Person p2("关羽",20);
    Person p3("张飞",20);
    Person p4("Tom",40);
    Person p5("Tom",60);
    v.push_back(p1);
    v.push_back(p2);
    v.push_back(p3);
    v.push_back(p4);
    v.push_back(p5);

    Person p("诸葛亮",20);
int num =count(v.begin(),v.end(),p);
cout<<"和诸葛亮同岁数的人数有"<<num<<"个"<<endl;
}

int main(){
    test01();
    test02();
    system("pause");
    return 0;
}

(六)count_if

功能描述:

  • 按条件统计元素个数

函数原型:

  • count_if(iterator beg,iterator end ,_Pred);

//按条件统计元素出现个数

//beg开始迭代器

//end 结束迭代器

//_Pred谓词

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//常用查找算法 count_if
//统计内置数据类型
class Greater20{
    public:
        bool operator()(const int& x)const{
            return x>20;
        }
};
void test01(){
    vector<int> v;
    v.push_back(10);
    v.push_back(20);
    v.push_back(30);
    v.push_back(40);
    v.push_back(50);
    int num =count_if(v.begin(),v.end(),Greater20());
    cout<<"大于20的数有"<<num<<"个"<<endl;

}

//统计自定义数据类型

class Person{
public:
    Person(string name,int age){
        this->m_name=name;
        this->m_age=age;
    }
    string m_name;
    int m_age;
};
class AgeGreater20{
public:
    bool operator()(const Person& p)const{
        return p.m_age>20;
    }
};
void test02(){
    vector<Person> v;
    Person p1("Tom",20);
    Person p2("Jerry",30);
    Person p3("Mike",40);
    Person p4("Lucy",50);
    v.push_back(p1);
    v.push_back(p2);
    v.push_back(p3);
    v.push_back(p4);
    int num =count_if(v.begin(),v.end(),AgeGreater20());
    cout<<"年龄大于20的有"<<num<<"个"<<endl;

}
int main(){
    test01();
    test02();
    system("pause");
    return 0;
}

三、常用的排序算法

算法简介:

  • sort    //对容器内元素进行排序
  • random_shuffle  //洗牌 指定范围内的元素随机调整次序
  • merge  //容器元素合并,并存储到另一容器中
  • reverse  //反转指定范围的元素

(一)sort

功能描述:

  • 对容器内元素进行排序

函数原型:

  • sort(iterator beg,iterator end ,_Pred);

//beg 开始迭代器

//end 结束迭代器

 //Pred 谓词

#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
//常用排序算法 sort
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int>v;
    v.push_back(3);
    v.push_back(1);
    v.push_back(4);
    v.push_back(2);
    v.push_back(5);
    //升序排序
    sort(v.begin(),v.end());
    for_each(v.begin(),v.end(),myPrint);
    //改为降序
    cout<<endl;
    sort(v.begin(),v.end(),greater<int>());
    for_each(v.begin(),v.end(),myPrint);

}

int main(){
    test01();
    system("pause");
    return 0;
}

(二)random_shuffle

功能描述:

  • 洗牌 指定范围内的元素随机调整次序

函数原型:

  • random_shuffle(iterator beg,iterator end);

//指定范围内的元素随机调整次序

//beg 开始迭代器

//end 结束迭代器

#include <iostream>
#include <algorithm>
#include <vector>
#include <ctime>
using namespace std;
//常用排序算法 random_shuffle()
void myPrint(int val){
    cout<<val<<" ";
}
void test01()
{   
    srand((unsigned)time(NULL));
    vector<int>v;
    for(int i=0;i<10;i++)
    {
        v.push_back(i);
    }
    random_shuffle(v.begin(),v.end());
    for_each(v.begin(),v.end(),myPrint);
    cout<<endl;

}
int main() {
    test01();
    system("pause");
    return 0;
}

总结:random_shuffle洗牌算法比较实用,使用时记得加随机数种子

(三)merge

功能描述:

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

函数原型:

  • merge(iterator beg1,iterator end1,iterator beg2,iterator end2,iterator dest);

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

//注意:两个容器必须是有序的

//beg1  容器1开始迭代器

//end1 容器1结束迭代器

//beg2  容器2开始迭代器

//end2 容器2结束迭代器

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//常用的排序算法 merge
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int>v1;
    vector<int>v2;
    for(int i=0;i<10;i++){
        v1.push_back(i);
        v2.push_back(i+1);
    }
    //目标容器
    vector<int>v3;
    v3.resize(v1.size()+v2.size());//提前预留空间
    //合并两个容器
    merge(v1.begin(),v1.end(),v2.begin(),v2.end(),v3.begin());
    for_each(v3.begin(),v3.end(),myPrint);
    cout<<endl;
}
int main() {
    test01();
    system("pause");
    return 0;
}

总结:merge合并的两个容器必须是有序序列,并且合并后的容器仍然是有序序列

(四)reverse

功能描述:

  • 将容器中的元素进行反转

函数原型:

  • reverse(iterator beg,iterator end);

//反转指定范围的元素

//beg开始迭代器

//end结束迭代器

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//常用的排序算法 reverse
using namespace std;
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int>v;
    v.push_back(1);
    v.push_back(3);
    v.push_back(2);
    v.push_back(5);
    v.push_back(4);
    cout<<"反转前:"<<" ";
    for_each(v.begin(),v.end(),myPrint);
    cout<<endl;
    cout<<"反转后:"<<" ";
    reverse(v.begin(),v.end());
    for_each(v.begin(),v.end(),myPrint);
    cout<<endl;

}

int main(){
    test01();
    system("pause");
    return 0;
}

四、常用拷贝和替换算法

算法简介:

  • copy  //容器内指定范围的元素拷贝到另一容器中
  • replace  //将容器内指定范围的旧元素修改为新元素
  • repace_if  //容器内指定范围满足条件的元素替换为新元素
  • swap  //互换两个容器的元素

(一)copy

功能描述:

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

函数原型:

  • copy(iterator beg,iterator end,iterator dest);

//beg 开始迭代器

//end 结束迭代器

//dest 目标起始迭代器

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//常用拷贝和替换算法
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int> v1;
    for(int i=0;i<10;i++){
        v1.push_back(i);
    }
    vector<int>v2;
    v2.resize(v1.size());
    copy(v1.begin(),v1.end(),v2.begin());
    for_each(v2.begin(),v2.end(),myPrint);
}
int main(){
    test01();
    system("pause");
    return 0;
    
}

(二)replace

功能描述:

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

//将区间内旧元素替换成新元素

//beg 开始迭代器

//end 结束迭代器

//oldvalue 就元素

//new value 新元素

 

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//常用拷贝和替换算法 replace
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int>v1;
    v1.push_back(10);
    v1.push_back(20);
    v1.push_back(30);
    v1.push_back(40);
    v1.push_back(30);
    v1.push_back(30);
    v1.push_back(40);
    cout<<"替换前"<<endl;
    for_each(v1.begin(),v1.end(),myPrint);
    cout<<endl;
    cout<<"替换后"<<endl;
    replace(v1.begin(),v1.end(),30,300);
    for_each(v1.begin(),v1.end(),myPrint);
}
int main(){
    test01();
    system("pause");
    return 0;
}

(三)replace_if

功能描述:

  • 将区间内满足条件的元素,替换成指定元素

函数原型:

  • replace_if(iterator beg,iterator end,_pred,newvalue);

//按照条件替换元素,满足条件的替换成指定元素

//beg开始迭代器

//end 结束迭代器

//-Pred谓词

//newvalue 替换成的新元素

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//常用拷贝和替换算法
void myPrint(int val){
    cout<<val<<" ";
}
class MyReplace{
public:
    bool operator()(const int &val)const{
        return val>20;
    }
};
void test01(){
    vector<int>v;
    v.push_back(20);
    v.push_back(30);
    v.push_back(40);
    v.push_back(40);
    v.push_back(60);
    v.push_back(10);
    v.push_back(80);
    v.push_back(20);
    v.push_back(90);
    cout<<"替换前:"<<" ";
    for_each(v.begin(),v.end(),myPrint);
    cout<<endl;
    cout<<"替换后:"<<" ";
    replace_if(v.begin(),v.end(),MyReplace(),1000);
    for_each(v.begin(),v.end(),myPrint);
}
int main(){
    test01();
    system("pause");
    return 0;
}

(四)swap

 功能描述:

  • 互换两个容器的元素

函数原型:

  • swap(container c1,container c2);

//互换两个容器的元素

//c1容器1

//c2容器2

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int> v1;
    vector<int> v2;
    for(int i=0;i<10;i++){

        v1.push_back(i);
        v2.push_back(i+100);
    }
    cout<<"交换前:"<<"v1"<<" ";
    for_each(v1.begin(),v1.end(),myPrint);
    cout<<endl;
    cout<<"交换前:"<<"v2"<<" ";
    for_each(v2.begin(),v2.end(),myPrint);
    cout<<endl;
    swap(v1,v2);
     cout<<"交换后:"<<"v1"<<" ";
    for_each(v1.begin(),v1.end(),myPrint);
    cout<<endl;
    cout<<"交换后:"<<"v2"<<" ";
    for_each(v2.begin(),v2.end(),myPrint);


}
int main(){
    test01();
    system("pause");
    return 0;
}

五、常用的算数生成算法

注意:

  • 算数生成算法属于小型算法,使用时包含的头文件为#include <numeric>

算法简介:

  • accumulate  //计算容器元素累计总和
  • fill  //向容器中添加元素

(一)accumulate

功能描述:

  • 计算区间内容器元素累计总和

函数原型:

  • accumulate(iterator beg,iterator end,value);

//计算容器元素累计总和

//beg 开始迭代器

//end 结束迭代器

//value 起始值

#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

//常用算数生成算法
void test01(){
    vector<int> v;
    for(int i=1;i<=100;i++){
        v.push_back(i);
    }
    
    int sum =accumulate(v.begin(),v.end(),0);
    cout<<"sum:"<<sum<<endl;
}

int main(){
    test01();
    system("pause");
    return 0;
}

(二)fill 

功能描述:

  • 像容器中填充指定的元素

函数原型:

  • fill(iterator beg,iterator end,value);

//向容器中填充元素

//beg 开始迭代器

//end 结束迭代器

//value 填充的值

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
void myPrint(int x){
    cout<<x<<" ";
}
//常用算数生成算法 fill
void test01(){
    vector<int> v;
    v.resize(10); //需要扩容
    fill(v.begin(),v.end(),100);
    for_each(v.begin(),v.end(),myPrint);
    cout<<endl;
}
int main(){
    test01();
    system("pause");
    return 0;

}

六、常用集合算法

算法简介:

  • set_intersection  //求两个容器的交集
  • set_union  //求两个容器的并集
  • set_difference //求两个容器的差集

(一)set_intersection

功能描述:

  • 求两个容器的交集

函数原型:

  • set_intersection(iterator beg1,iterator end1,iterator beg2,iterator end2,iterator dest);

//求两个集合的交集

//注意:两个集合必须是有序序列

//beg1 容器1开始迭代器

//end1 容器1结束迭代器

//beg2 容器2开始迭代器

//end2 容器2结束迭代器

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void myPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int>v1;
    vector<int>v2;
    vector<int>v3;
    for(int i=0;i<10;i++){
        v1.push_back(i);
        v2.push_back(i+5);
    }
    //目标容器提前开辟空间
    //最特殊情况 大容器包含了小容器  --》取小容器即可
    v3.resize(min(v1.size(),v2.size()));
    //获取交集
    vector<int>::iterator itEnd = set_intersection(v1.begin(),v1.end(),v2.begin(),v2.end(),v3.begin());
    for_each(v3.begin(),v3.end(),myPrint);
    cout<<endl;
    for_each(v3.begin(),itEnd,myPrint);  //交集计算后的迭代器
    cout<<endl;

}

int main() {
    test01();
    system("pause");
    return 0;
}

(二)set_union

功能描述:

  • 求两个集合的并集

函数原型:

  • set_union(iterator beg1,iterator end1,iterator beg2,iterator end2,iterator dest);

//求两个集合的并集

//注意:两个集合必须是有序序列

//beg1 容器1开始迭代器

//end1 容器1结束迭代器

//beg2 容器2开始迭代器

//end2 容器2结束迭代器

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//常用集合算法Union
void MyPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int> v1;
    vector<int> v2;
    vector<int> v3;
    for(int i=0;i<10;i++){
        v1.push_back(i);
        v2.push_back(i+5);
    }
    v3.resize(v1.size()+v2.size());
    //合并两个集合
    vector<int>::iterator itEnd = set_union(v1.begin(),v1.end(),v2.begin(),v2.end(),v3.begin());
    for_each(v3.begin(),v3.end(),MyPrint);
    cout<<endl;
    for_each(v3.begin(),itEnd,MyPrint);
    
}

int main(){
    test01();
    system("pause");
    return 0;
}

(三)set_difference

功能描述:

  • 求两个集合的差集

函数原型:

  • set_difference(iterator beg1,iterator end1,iterator beg2,iterator end2,iterator dest);

//求两个集合的并集

//注意:两个集合必须是有序序列

//beg1 容器1开始迭代器

//end1 容器1结束迭代器

//beg2 容器2开始迭代器

//end2 容器2结束迭代器

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//求两个集合的差集
void MyPrint(int val){
    cout<<val<<" ";
}
void test01(){
    vector<int>v1;
    vector<int>v2;
    vector<int>v3;
    vector<int>v4;
    for(int i=0;i<10;i++){
        v1.push_back(i);
        v2.push_back(i+5);
    }
    v3.resize(max(v1.size(),v2.size()));
    v4.resize(max(v1.size(),v2.size()));
    
    //取差集
    vector<int>::iterator itEnd=set_difference(v1.begin(),v1.end(),v2.begin(),v2.end(),v3.begin());
    //输出差集
    cout<<"v1-v2的交集"<<endl;
    for_each(v3.begin(),v3.end(),MyPrint);
    cout<<endl;
    for_each(v3.begin(),itEnd,MyPrint);
    cout<<endl;
    cout<<"v2-v1的交集"<<endl;
    vector<int>::iterator itEnd2=set_difference(v2.begin(),v2.end(),v1.begin(),v1.end(),v4.begin());
    for_each(v4.begin(),v4.end(),MyPrint);
    cout<<endl;
    for_each(v4.begin(),itEnd2,MyPrint);
    cout<<endl;
    

}
int main(){
    test01();
    system("pause");
    return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2088522.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

华硕天选Air:开学季的性价比之巅

正值开学季&#xff0c;华硕天选Air全能本以8999元的首发价回归&#xff0c;为学生和需求高性能笔记本的用户带来了超值的选择。 这款笔记本以其轻薄设计和强悍性能&#xff0c;成为市场上的热点。 轻薄设计&#xff0c;潮流先锋 华硕天选Air 2024采用了全新模具设计&#xf…

如何选择生信云服务器

少走弯路,高效分析;了解生信云,访问 【生信圆桌x生信专用云服务器】 : www.tebteb.cc 生物信息学&#xff08;生信&#xff09;分析的需求日益增加&#xff0c;选择一款合适的生信云服务器变得尤为重要。一个优秀的生信云服务器不仅能够提供强大的计算能力和灵活的存储空间&…

【数据结构】排序算法篇一

【数据结构】排序算法篇一 1. 插入排序&#xff08;1&#xff09;基本思想&#xff1a;&#xff08;2&#xff09;动态图解&#xff1a;&#xff08;3&#xff09;具体步骤&#xff1a;&#xff08;4&#xff09;代码实现&#xff1a;&#xff08;5&#xff09;特性总结&#x…

数据治理下的主数据管理与KPaaS的应用

在2024中国国际大数据产业博览会&#xff08;简称“数博会”&#xff09;上&#xff0c;数据治理作为大数据领域的热点主题之一&#xff0c;引起了广泛关注。这一议题之所以成为焦点&#xff0c;是因为在数字化时代&#xff0c;数据已经上升为企业最具价值的战略资源之一。随着…

【区块链 + 智慧文旅】城商行旅游金融联盟:旅游金融联盟平台 | FISCO BCOS应用案例

深圳优讯基于FISCO BCOS搭建面向联盟成员间使用的开 放式客户服务平台&#xff0c;平台于2018年6月底上线。 成员机构之间共享产品、流量、征信和金融资源&#xff0c;整合旅游产业链资源&#xff0c;实现跨地域的旅游金融协作。

【STM32单片机_(HAL库)】3-3【中断EXTI】使用SysTick模拟多线程

1.硬件 STM32单片机最小系统 LED灯模块 硬件接线 STM32LED1LED2PB8负极PB9负极5V5V5V 2.软件 led、tasks驱动文件添加GPIO常用函数main.c程序 #include "sys.h" #include "delay.h" #include "led.h" #include "tasks.h"int mai…

.NET HandyControl 深度解析:一个现代化的UI控件库

文章目录 前言一、选择HandyControl的原因二、如何使用HandyControl1.安装HandyControl2.使用代码例子 总结 前言 在.NET开发领域&#xff0c;UI&#xff08;用户界面&#xff09;设计的美观性和易用性对于应用程序的成功至关重要。为了帮助开发者快速构建现代化、美观且用户友…

日常避坑指南:重试装饰器的正确使用方式

在日常开发中,重试机制是提高代码健壮性的重要手段之一,尤其是在处理网络请求时,遇到超时或临时性错误的情况并不少见。通过重试,我们可以在一定程度上降低这些临时问题带来的影响。然而,如果使用不当,重试机制本身也可能引发新的问题,甚至让问题更加难以排查。 问题背…

Framework | Android语音识别框架与语音交互概览

Framework | Android语音识别框架与语音交互概览 随着智能设备的普及,语音识别与语音交互技术在现代生活中扮演着越来越重要的角色。无论是在驾驶场景中解放用户的双手,还是在智能家居中通过语音控制设备,语音技术的应用场景已经深入到各个领域。本文将深入探讨Android平台…

Live800:数字化转型下的客户服务新生态

在数字化转型的浪潮中&#xff0c;企业客户服务领域正经历着前所未有的变革。数字技术如大数据、云计算、人工智能和物联网等&#xff0c;不仅重塑了企业的运营模式&#xff0c;更深刻地改变了客户服务的面貌&#xff0c;构建了一个全新的客户服务生态。 一、数字化转型的驱动力…

在docker中安装skywalking + es

ES的版本和官网 es版本&#xff1a; Past Releases of Elastic Stack Software | Elastic es版本logstash版本JDK版本对应关系 支持一览表 | Elastic skywalking的版本说明和官网 Advanced deployment | Apache SkyWalking skywalking和es的对应关系&#xff0c;在网页的…

实训第三十二天(学习playbook-roles,脚本创建数据库和表,mycat读写分离)

1、roles&#xff08;角色&#xff09;介绍 roles(⻆⾊): 就是通过分别将variables, tasks及handlers等放置于单独 的⽬录中,并可以便捷地调⽤它们的⼀种机制。 假设我们要写⼀个playbook来安装管理lamp环境&#xff0c;那么这个 playbook就会写很⻓。所以我们希望把这个很⼤的…

Native开发与逆向第二篇 - 动态注册函数逆向

ida静态分析 示例app是网上找的一个杀毒软件&#xff0c;做安全的app防护应该是OK的。 直接找到JNI_OnLoad 类名没处理&#xff0c;直接是明文。 jint JNI_OnLoad(JavaVM *vm, void *reserved) {jint v2; // w19__int64 v4; // [xsp0h] [xbp-30h] BYREFqword_25148 vm;if ( …

全免费的数据恢复工具推荐!这几个不容错过!

不小心的数据丢失总会带来许多困扰&#xff0c;不过这些困扰也能通过一些全免费的数据恢复工具解决。接下来&#xff0c;就来给大家介绍几款好用的数据恢复工具&#xff01; 第一款&#xff1a;福昕数据恢复 直达链接&#xff1a;www.pdf365.cn/foxit-restore/ 福昕数据恢复…

6.2K star!推荐一款开源混沌工程测试平台:Chaos Mesh

1、Chaos Mesh 介绍 Chaos Mesh是一个开源的混沌工程平台&#xff0c;旨在帮助用户在生产环境中测试、验证和优化其应用程序的可靠性和稳定性。通过引入故障注入和混沌工程原则&#xff0c;Chaos Mesh可以模拟各种故障场景&#xff0c;如网络延迟、节点故障、磁盘故障等&#…

【spring】学习笔记1:starter和application

https://spring.io/toolsSpring Boot Extension Pack vs版本 使用Spring Tool Suite初始化Spring项目

如何将本地的hexo博客部署到云服务器

云服务器系统&#xff1a;centos 7 本地电脑 mac 第一步&#xff1a; 初始化Hexo博客 npm install hexo-cli -g hexo init HexoBlog 注意node版本需要16以上 cd HexoBlog hexo server访问地址localhost:4000 云服务器执行以下操作 配置的ssh访问用户 useradd git passw…

知网硕士论文稿酬领取方式

目录 知网硕士论文稿酬领取方式: 建议:版税制付酬 版税 知网 学位年度2008年(含2008年)以后的稿酬标准 知网硕士论文稿酬领取方式: 建议:版税制付酬 你怎么能把自己看死了,以后有大用。 中国知网是由清华大学、清华同方发起,始建于1999年6月,是以实现全社会知识…

一文300字从0到1使用Postman轻松搞定文件上传测试!

postman经常用于接口测试&#xff0c;但是上传文件参数还是蛮复杂的&#xff0c;记录下过程 01、上传文件参数 1.选择请求方式 选择post请求方式&#xff0c;输入请求地址 2.填写Headers Key&#xff1a;Content-Type &#xff1b; Value&#xff1a;multipart/form-data …

【数学建模】层次分析法

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站。前言 – 人工智能教程 在数学建模问题求解中什么时候用到层次分析法 在数学建模问题求解中&#xff0c;层次分析法&#xff08;Analytic…