title is not very informative but basically what I am trying to do is run a check against a txt file and find words that contain what i'm looking for.
The following code does it correctly and exactly how i want it to do it. BUT!
void qu()
{
for (Word word : word2)
{
string uq = word.getWord();
if (uq.find("qa") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qb")!= std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qc") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qd") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qe") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qf") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qg") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qh") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qi") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qj") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qk") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("ql") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qm") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qn") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qo") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qp") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qq") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qr") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qs") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qt") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qv") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qw") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qx") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qy") != std::string::npos)
{
cout << uq << '\n';
}
else if (uq.find("qz") != std::string::npos)
{
cout << uq << '\n';
}
}
}
I would like to do it in a more tidy way.
If someone could point me in the right direction like a cplusplus refernce link or another documentation that would be awesome.
Aucun commentaire:
Enregistrer un commentaire