string转化大小写: transform
https://blog.csdn.net/o_ohello/article/details/88636667
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
string s = "AakoOO";
transform(s.begin(), s.end(), s.begin(), ::toupper);
cout<<s<<endl;
transform(s.begin(), s.end(), s.begin(), ::tolower);
cout<<s<<endl;
return 0;
}
”删除”序列中所有相邻的重复元素(只保留一个)。unique
https://www.cnblogs.com/wangkundentisy/p/9033782.html
unique删除出并非真的函数,只是被不重复的元素给占领了。
删除的是相邻的元素,所以需要先排好序。
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
static bool myfunc(int i, int j)
{
return (i + 1) == j;
//return i == j;
}
int main()
{
vector<int> a = {1,3,3,4,5,6,6,7};
vector<int>::iterator it_1 = a.begin();
vector<int>::iterator it_2 = a.end();
//sort(it_1,it_2);
cout<<"去重前的 a : ";
for(int i = 0 ; i < a.size(); i++)
cout<<a[i];
cout<<endl;
//it_h = unique(it_1,it_2);
//unique(it_1,it_2,myfunc);
unique(it_1,it_2);
cout<<"去重后的 a : ";
for(int i = 0 ; i < a.size(); i++)
cout<<a[i];
cout<<endl;
}
swap函数
int main()
{
int a = 1;
int b = 2;
swap(a ,b);
cout <<a << " " << b << endl; // 2 1
}
equal_range
lower_bound函数
https://www.cnblogs.com/fnlingnzb-learner/p/6005169.html
fill函数
int v[10];
int main()
{
fill(v,v+10,-1);
for (int i = 0; i <10; ++i)
printf("%d ",v[i]);
// -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
}