标准模板2
#include<iostream>
#include<list>
#include<string>
#include<numeric>
#include<iterator>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
int main()
{
char cList[10]={'A','B','C','D','F','G','H','I','J','K'};
vector<char> charList(cList,cList+10);
vector<char>::iterator charItr;
ostream_iterator<char> screen(cout," ");
cout<<"charList:"<<endl;
copy(charList.begin(),charList.end(),screen);
cout<<endl;
swap(charList[0],charList[1]);
cout<<"charList.swap"<<endl;
copy(charList.begin(),charList.end(),screen);
cout<<endl;
charItr=charList.begin()+4;
iter_swap(charItr,charItr+1);
cout<<"charList.iter_swap"<<endl;
copy(charList.begin(),charList.end(),screen);
cout<<endl;
int list[10]={1,2,3,4,5,6,7,8,9,10};
vector<int> intList(list,list+10);
ostream_iterator<int> screenInt(cout," ");
cout<<"intList:"<<endl;
copy(intList.begin(),intList.end(),screenInt);
cout<<endl;
swap_ranges(intList.begin(),intList.begin()+4,intList.begin()+5);
cout<<"intList.swap_ranges:"<<endl;
copy(intList.begin(),intList.end(),screenInt);
cout<<endl;
swap_ranges(list,list+10,intList.begin());
cout<<"list:"<<endl;
copy(list,list+10,screenInt);
cout<<endl;
cout<<"intList:"<<endl;
copy(intList.begin(),intList.end(),screenInt);
cout<<endl;
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?