#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <list>
#include <set>
#include <cstdlib>
#include <functional>
using namespace std;
struct string_length_exceeds
{
string_length_exceeds(int n): limit(n){}
bool operator()(const string& s)
{
return s.size()>limit;
}
int limit;
};
int main()
{
char A[]="abcdefgh";
vector<char> V(A,A+strlen(A));
list<char> L;
copy(V.begin(),V.end(),back_inserter(L));
copy(L.begin(),L.end(),ostream_iterator<char>(cout," "));
swap()//
int x=1;
int y=2;
swap(x,y);
cout<<x<<" "<<y<<endl;
///swap_ranges///
vector<int> v1;
v1.push_back(1);
v1.push_back(2);
vector<int> v2;
v2.push_back(3);
v2.push_back(4);
swap_ranges(v1.begin(),v1.end(),v2.begin());
copy(v1.begin(),v1.end(),ostream_iterator<int>(cout," "));
cout<<endl;
copy(v2.begin(),v2.end(),ostream_iterator<int>(cout," "));
cout<<endl;
transform//
const int N=7;
double B[N]={1,2,3,4,5,6,7};
list<double> L3(N);
transform(B,B+N,L3.begin(),negate<double>());
copy(L3.begin(),L3.end(),ostream_iterator<double>(cout," "));
cout<<endl;
///replace///
vector<string> fruits;
fruits.push_back("cherry");
fruits.push_back("apple");
fruits.push_back("peach");
fruits.push_back("apple");
fruits.push_back("cherry");
replace(fruits.begin(),fruits.end(),string("apple"),string("orange"));
copy(fruits.begin(),fruits.end(),ostream_iterator<string>(cout," "));
cout<<endl;
/replace_if()/
vector<double> Ve;
Ve.push_back(1);
Ve.push_back(-3);
Ve.push_back(2);
Ve.push_back(-1);
replace_if(Ve.begin(),Ve.end(),bind2nd(less<double>(),0),11);
copy(Ve.begin(),Ve.end(),ostream_iterator<double>(cout," "));
cout<<endl;
///replace_if()///
string str[7]={"oxygen","carbon","nitrgen","iron","sodiym","hydrogen","silicon"};
replace_if(str,str+7,string_length_exceeds(6),"&&&");
copy(str,str+7,ostream_iterator<string>(cout," "));
cout<<endl;
//replace_copy()
return 0;
}