一.swap
int a=1,b=2;
swap(a,b);
//此时a=2,b=1
二.reverse
int a[5]={1,2,3,4,5};
reverse(a,a+5);
//序列现在是 5 4 3 2 1

char s[]="ericxie";
reverse(s,s+strlen(s));
//序列现在是 "eixcire"
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std; 
int main(int argc, char *argv[])
 {
     string s="qwer";
reverse(s.begin(),s.end());
cout<<s;
	return 0;
}

C++ with STL(一)_C

三.__gcd

#include <iostream>
#include<algorithm>
using namespace std; 
int main(int argc, char *argv[])
 {
     int a=15,b=6;
int c=__gcd(a,b);
cout<<c;
	return 0;
}

C++ with STL(一)_ios_02

#include <iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int a[4]={2,9,3,1};
	do{
		for(int i=0;i<4;i++)
		cout<<a[i];
		cout<<endl;
	}while(next_permutation(a,a+4));
	sort(a,a+4,cmp);
	for(int i=0;i<4;i++)
		cout<<a[i]<<' ';
	cout<<endl;
	sort(a,a+4);
	int p=lower_bound(a,a+4,4)-a;
	//if(a[p]=3) 查找成功!
	int t=upper_bound(a,a+4,2)-a;
	cout<<p<<endl;
	cout<<t<<endl;
	int b[6]={1,1,2,2,3,3};
	int c=unique(b,b+6)-b;
	for(int i=0;i<c;i++)
	{
	cout<<b[i]<<' '<<endl;
	}
	int d=sizeof(b)/sizeof(int);
	cout<<d;
system("pause");
	return 0;
}

C++ with STL(一)_#include_03

#include <iostream>
#include<string>
using namespace std;
int main()
{
string s="abc";
string s1,s2,s3,s4;
s1=s.substr(0,2);
cout<<s1<<endl;
s2=s.insert(0,2,'a');
cout<<s2<<endl;
s3=s.insert(1,"hh");
cout<<s3<<endl;
s4=s.erase(0,4);
cout<<s4<<endl;
system("pause");
	return 0;
}

C++ with STL(一)_C_04