我写了函数。但老师告诉我,在3 个的参数的std::count_if功能,有必要通过拉姆达找出如果这封信是元音。
我不知道如何在那里转移它。
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;
}
Run Code Online (Sandbox Code Playgroud)