123456789101112131415161718 |
- /* Create a function that takes a string as an argument
- ~ and returns a coded (h4ck3r 5p34k) version of the string.
- ~ In order to work properly, the function should replace
- ~ all 'a's with 4, 'e's with 3, 'i's with 1, 'o's with 0, and 's's with 5.
- */
- std::string hackerSpeak(std::string str) {
- std::string empty = "";
- for (int i=0;i<str.size();i++){
- switch(str[i]) {
- case 'a' : str.replace(i,1,"4"); break;
- case 'e' : str.replace(i,1,"3"); break;
- case 'i' : str.replace(i,1,"1"); break;
- case 'o' : str.replace(i,1,"0"); break;
- case 's' : str.replace(i,1,"5"); break;
- }
- }
- return str;
- }
|