1.判断vector只出现过一次的数字用异或
string用find和rfind
2.判断多数元素 先排序然后取a[length/2]的元素
3.vector中的删除元素
利用迭代器find!!!!!!
vector<int>a;
int target; //要删除的值
for(vector<int>::iterator it=a.begin();it!=a.end();)
{
if((*it)==target)
{
it=a.erase(it);
}
else
it++;
}
4.reverse函数能反转字符,数组
string temp="temp";
reverse(temp.begin(),temp.end()); //此时temp输出为 pmet
5.#include<cctype>中的函数
isdigit() 判断是否为数字
isalpha() 判断是否为字母
isalnum() 判断是否为字母或数字
islower() 判断是否为小写字母
isupper() 判断是否为大写字母
6.string中的find()
可以指定位置进行查找
string temp="Hello world";
int a=temp.find('l',5); //从第五位以后开始查找
可以查找第一次出现的位置和最后一次出现的位置
string temp="hello world";
cout<<temp.find_first_of('h'); // 第一次出现的位置
cout<<temp.find_last_of('h'); // 最后一次出现的位置