#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
template<typename T>
void prinfVector(vector<T> &nums) {
for (const auto &c : nums)
cout << c << " ";
cout << endl;
}
int main() {
vector<string> strNum = { "oppo","huawei","oppo", "xiaomi","vivo", "xiaomi", "apple" };
sort(strNum.begin(), strNum.end(), [](const string &a, const string &b)
{return a.size() < b.size(); });
prinfVector(strNum);
auto end_iterator = unique(strNum.begin(), strNum.end());
prinfVector(strNum);
strNum.erase(end_iterator, strNum.end());
prinfVector(strNum);
}
删除字符串数组中相同的字符串
最新推荐文章于 2022-11-08 23:16:27 发布