1234567891011121314151617181920212223242526272829303132 |
- bool isVowel(char c){
- c = tolower(c);
- return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
- }
- std::string spoonerise(std::string phrase) {
-
- std::size_t p = phrase.find(' ');
- std::string fw = phrase.substr(0,p), sw = phrase.substr(p+1);
-
- std::string fp = "", sp = "";
-
- while(!isVowel(fw[0])){
- fp.push_back(fw[0]);
- fw.erase(fw.begin());
- }
-
- while(!isVowel(sw[0])){
- sp.push_back(sw[0]);
- sw.erase(sw.begin());
- }
- return sp + fw + ' ' + fp + sw;
- }
|