Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Olga Rún Kristjánsdóttir
- //2303892179
- //olgak10@ru.is
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- void make_lower (string& first, string& last)
- {
- for (int i = 0; i < first.length ();i++)
- {
- first [i] = tolower(first[i]);
- }
- for (int j = 0; j< last.length ();j++)
- {
- last [j] = tolower(last [j]);
- }
- first [0] = toupper(first [0]);
- last [0] = toupper(last [0]);
- }
- void pig_latin_string (string& first, string& last, vector<char>& pig_first, vector<char>& pig_last)
- {
- //vector <char> pig_first;
- //vector <char>pig_last;
- char array_consonants [] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','z'};
- char array_vowels [] = {'a','e','i','o','u','y'};
- for (int i = 0;i<21;i++)
- {
- if (first [0] == array_consonants [i])
- {
- for (int t = 1; t < first.length();t++)
- {
- pig_first.push_back(first [t]);
- }
- pig_first.push_back (first [0]);
- pig_first.push_back ('a');
- pig_first.push_back ('y');
- }
- if (last [0] == array_consonants [i])
- {
- for (int o = 1; o < last.length();o++)
- {
- pig_last.push_back (last[o]);
- }
- pig_last.push_back (last [0]);
- pig_last.push_back ('a');
- pig_last.push_back ('y');
- }
- }
- for (int j = 0; j<7; j++)
- {
- if (first [0] == array_vowels [j])
- {
- for (int z = 0;z<first.length (); z++)
- {
- pig_first.push_back(first [z]);
- }
- pig_first.push_back ('w');
- pig_first.push_back ('a');
- pig_first.push_back ('y');
- }
- if (last [0] == array_vowels [j])
- {
- for (int u =0; u<last.length (); u++)
- {
- pig_last.push_back (last[u]);
- }
- pig_last.push_back ('w');
- pig_last.push_back ('a');
- pig_last.push_back ('y');
- }
- }
- }
- void print_results (vector<char>& pig_first, vector<char>& pig_last)
- {
- for (unsigned int f = 0; f <pig_first.size (); f++)
- {
- cout << pig_first[f];
- }
- cout << " ";
- for (unsigned int e = 0;e<pig_last.size();e++)
- {
- cout << pig_last [e];
- }
- }
- int main()
- {
- string firstname, lastname;
- vector <char> pig_first;
- vector <char>pig_last;
- cout << "enter your first and last name" << endl;
- cin >> firstname >> lastname;
- make_lower (firstname, lastname);
- pig_latin_string (firstname, lastname, pig_first, pig_last);
- print_results (pig_first, pig_last);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement