我写了函数,但是老师告诉我,在std::count_if
函数的第3个参数中,必须传递来确定字母是否为元音。 我不知道如何在那里转移它。
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;
}
我编写了函数,但是老师告诉我,在std :: count_if函数的第三个参数中,有必要传递lambda来确定字母是否为元音。我不知道如何...