Guest User

Untitled

a guest
Feb 6th, 2019
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. import java.util.*;
  2. public class S2 {
  3.     public static void main(String[] args) {
  4.         Scanner s = new Scanner(System.in);
  5.         int x = Integer.parseInt(s.nextLine());
  6.         for(int i = 0; i < x; i++) {
  7.             String[] A = new String[4];
  8.             for(int j = 0; j < 4; j++) {
  9.                 String r = s.nextLine().toLowerCase();
  10.                 int k = lastVowel(r);
  11.                 if(k == -1)
  12.                     A[j] = r;
  13.                 else if(k == r.length() - 1)
  14.                     A[j] = "";
  15.                 else
  16.                 A[j] = r.substring(k, r.length() - 1);
  17.             }
  18.             if(A[0].equals(A[2]) && A[0].equals(A[1]) && A[0].equals(A[3]))
  19.                 System.out.println("perfect");
  20.             else if (A[0].equals(A[1]) && A[2].equals(A[3]))
  21.                     System.out.println("even");
  22.             else if (A[0].equals(A[2]) && A[1].equals(A[3]))
  23.                     System.out.println("cross");
  24.             else if (A[0].equals(A[3]) && A[1].equals(A[2]))
  25.                     System.out.println("shell");
  26.             else System.out.println("free");
  27.         }
  28.     }
  29.     static int lastVowel(String s) {
  30.         for(int i = s.length(); i > 0; i--) {
  31.             switch(s.charAt(i - 1)) {
  32.                 case ' ': return i - 1;
  33.                 case 'a': return i - 1;
  34.                 case 'e': return i - 1;
  35.                 case 'i': return i - 1;
  36.                 case 'o': return i - 1;
  37.                 case 'u': return i - 1;
  38.             }
  39.         } return -1;
  40.     }
  41. }
Add Comment
Please, Sign In to add comment