/ Published in: C++
you enter in a string, and it will convert the consonants to 1's, and the vowels to 0's. spaces are not really supported, replace spaces with ".", or "-".
Expand |
Embed | Plain Text
#include <cstdlib> #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int i=0, j; string word; cin >> word; do{ if(word.at(i) == 'a'|| word.at(i) == 'e'|| word.at(i) == 'i'|| word.at(i) == 'o'|| word.at(i) == 'u') { word.replace(i, 1, "0"); i++; } else if(word.at(i) == 'b'|| word.at(i) == 'c'|| word.at(i) == 'd'|| word.at(i) == 'f'|| word.at(i) == 'g'|| word.at(i) == 'h'|| word.at(i) == 'j'|| word.at(i) == 'k'|| word.at(i) == 'l'|| word.at(i) == 'm'|| word.at(i) == 'n'|| word.at(i) == 'p'|| word.at(i) == 'q'|| word.at(i) == 'r'|| word.at(i) == 's'|| word.at(i) == 't'|| word.at(i) == 'v'|| word.at(i) == 'w'|| word.at(i) == 'x'|| word.at(i) == 'y'|| word.at(i) == 'z') { word.replace(i, 1, "1"); i++; } else if(word.at(i) == ' '||word.at(i) == '-'||word.at(i) == '.') { word.replace(i, 1, " "); i++; } system("cls"); cout << word << endl; }while (i != word.length()); system("pause"); }
You need to login to post a comment.
