Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n=1;
  9.     cin >> n;
  10.     cin.ignore(); // must use ignore in c++ before getline or cin.getline
  11.    
  12.     for(int i=0; i<n; i++) {
  13.         string s[4];
  14.            
  15.         for(int j=0; j<4; j++) {
  16.             getline(cin, s[j]); //we must use getline because regular cin ends at SPACES. getline includes spaces, until there is a newline \n
  17.            
  18.             //convert the verses into syllables (vowel + consonant at end)
  19.             for(int k=s[j].length()-1; k>=0; k--) {
  20.                 //loops through the end of the word until it reaches a space, vowel, or its at the start at the verse
  21.                 char c = tolower(s[j][k]); //must convert to lowercase
  22.                 if(c==' ' || k==0 || c =='a' || c =='e' || c =='i' || c =='o' || c =='u') {
  23.                     s[j] = s[j].substr(k); //gets the string starting at the vowel till the end of the verse
  24.                     //convert to lower
  25.                     transform(s[j].begin(), s[j].end(), s[j].begin(), ::tolower); //convert to lowercase
  26.                     break;
  27.                 }
  28.             }
  29.         }
  30.        
  31.         //simple conditionals
  32.         if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]) {
  33.             cout << "perfect" << endl;
  34.         } else if(s[0] == s[2] && s[1] == s[3]) {
  35.             cout << "cross" << endl;
  36.         } else if(s[0] == s[1] && s[2] == s[3]) {
  37.             cout << "even" << endl;
  38.         } else if(s[0] == s[3] && s[2] == s[1]) {
  39.             cout << "shell" << endl;
  40.         } else {
  41.             cout << "free" << endl;
  42.         }
  43.        
  44.     }
  45.  
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement