1 Star 0 Fork 1

llongger/Code_C++

forked from GodOuO/Code_C++ 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
87.merag.cpp 805 Bytes
一键复制 编辑 原始数据 按行查看 历史
GodOuO 提交于 2023-03-15 04:09 . Train
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class printIntVector
{
public:
void operator()(int a){
cout<<a<<" ; ";
}
};
//常用排序算法 merge
void test01(){
vector<int> v1;
vector<int> v2;
vector<int> vTarget;
for (int i = 0; i < 10; i++)
v1.push_back(i+1);
for (int i = 10; i < 15; i++)
v2.push_back(i+1);
vTarget.resize(v1.size()+v2.size());
for_each(v1.begin(),v1.end(),printIntVector());
cout<<endl;
for_each(v2.begin(),v2.end(),printIntVector());
cout<<endl;
merge(v1.begin(),v1.end(),v2.begin(),v2.end(),vTarget.begin());
for_each(vTarget.begin(),vTarget.end(),printIntVector());
cout<<endl;
}
int main(){
test01();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/llongger/codeCpp.git
git@gitee.com:llongger/codeCpp.git
llongger
codeCpp
Code_C++
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385