I wrote the function, but the teacher told me that in the 3 parameter of the count_if function it is necessary to pass the lambda to find out if the letter is vowel. And I can't figure out how to transfer it there. Help please.
unsigned CalculateVowels(const std::string& str)
{
const std::string& vowels = "aeiouAEIOU";
unsigned count = std::count_if(str.begin(), str.end(), [](int index) {return str[index] == vowels[index]; })
return count;
}
Aucun commentaire:
Enregistrer un commentaire