1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <iostream>
#include <string>
using namespace std;
string replace(char vowel, int nameLength, string str)
{
for (int i=0; i<nameLength; i++)
{
if (str[i] == vowel)
str[i]= 'z';
}
}
int main()
{
string firstName, lastName, fullName;
cout << "What is your first name, pal?\n";
cin >> firstName;
cout << "And your last name?\n";
cin >> lastName;
fullName = firstName + " " + lastName;
int nameLength = sizeof(fullName);
fullName = replace('a', nameLength, fullName);
fullName = replace('e', nameLength, fullName);
fullName = replace('i', nameLength, fullName);
fullName = replace('o', nameLength, fullName);
fullName = replace('u', nameLength, fullName);
cout << "Hey, " << firstName << " "<< lastName << endl;
return 0;
}
|