1234567891011121314151617181920 |
- bool isVowel(char c){
- c = tolower(c);
- return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
- }
- std::string firstNVowels(std::string str, int n) {
-
- std::string vowels = "";
-
- for(int i = 0;i<str.size();i++){
- if(isVowel(str[i])){
- vowels.push_back(str[i]);
- }
- }
- if(n <= vowels.size()){return vowels.substr(0,n);}
- else return "invalid";
- }
|