-
Notifications
You must be signed in to change notification settings - Fork 2
/
piglatin.cpp
82 lines (76 loc) · 1.39 KB
/
piglatin.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <unordered_set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void pySplit(string & splitString, char seperator, vector<string> & seperated)
{
int endIndex = 0;
seperated.clear();
seperated.push_back("");
for (unsigned int i = 0; i < splitString.size(); i++)
{
if (splitString[i] == seperator)
{
endIndex++;
seperated.push_back("");
}
else
{
seperated[endIndex] += splitString[i];
}
}
}
int main()
{
ull i, j, k;
string thing;
string temp;
vector<string> splitLine;
while (getline(cin, thing))
{
pySplit(thing, ' ', splitLine);
for (auto i : splitLine)
{
temp = "";
bool found = false;
if (i[0] == 'a' || i[0] == 'e' || i[0] == 'i'
|| i[0] == 'o' || i[0] == 'u' || i[0] == 'y')
{
temp = i + "yay";
}
else
{
j = 0;
while (j < i.size() && !found)
{
if (i[j] == 'a' || i[j] == 'e' || i[j] == 'i'
|| i[j] == 'o' || i[j] == 'u' || i[j] == 'y')
{
found = true;
}
j++;
}
j -= 1;
temp += i.substr(j);
temp += i.substr(0, j);
temp += "ay";
}
cout << temp << " ";
}
cout << "\n";
}
return 0;
}