Найти с хэш -набором
#include <unordered_set>
#include <string>
#include <iostream>
int main() {
std::unordered_set<std::string> planets{
{"Venus"},
{"Earth"},
{"Mars"},
};
auto it = planets.find("Earth");
if (it != planets.end()) {
std::cout << *it << "\n";
} else {
std::cout << "No such planet.\n";
}
it = planets.find("PlanetX");
if (it != planets.end()) {
std::cout << *it << "\n";
} else {
std::cout << "No such planet.\n";
}
}
Happy Horse