Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main() {
- int n=1;
- cin >> n;
- cin.ignore(); // must use ignore in c++ before getline or cin.getline
- for(int i=0; i<n; i++) {
- string s[4];
- for(int j=0; j<4; j++) {
- getline(cin, s[j]); //we must use getline because regular cin ends at SPACES. getline includes spaces, until there is a newline \n
- //convert the verses into syllables (vowel + consonant at end)
- for(int k=s[j].length()-1; k>=0; k--) {
- //loops through the end of the word until it reaches a space, vowel, or its at the start at the verse
- char c = tolower(s[j][k]); //must convert to lowercase
- if(c==' ' || k==0 || c =='a' || c =='e' || c =='i' || c =='o' || c =='u') {
- s[j] = s[j].substr(k); //gets the string starting at the vowel till the end of the verse
- //convert to lower
- transform(s[j].begin(), s[j].end(), s[j].begin(), ::tolower); //convert to lowercase
- break;
- }
- }
- }
- //simple conditionals
- if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]) {
- cout << "perfect" << endl;
- } else if(s[0] == s[2] && s[1] == s[3]) {
- cout << "cross" << endl;
- } else if(s[0] == s[1] && s[2] == s[3]) {
- cout << "even" << endl;
- } else if(s[0] == s[3] && s[2] == s[1]) {
- cout << "shell" << endl;
- } else {
- cout << "free" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement