Advertisement
Guest User

Simple Array Manipulation

a guest
Dec 27th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class ccc04s1
  4. {
  5.     public static void main (String[] args)
  6.     {
  7.         Scanner str = new Scanner(System.in);
  8.        
  9.         int counter = Integer.parseInt(str.next());
  10.        
  11.         for (int i = 0; i <= counter; i++)
  12.         {  
  13.             String [] words = new String [3];  
  14.             for (int j = 0; j <=2; j++)
  15.             {
  16.                 words [j] = str.nextLine();
  17.             }  
  18.             char pretemp = words[0].charAt(0);
  19.             char suftemp = words[0].charAt(words[0].length()-1);
  20.             String pre = Character.toString(pretemp);
  21.             String suf = Character.toString(suftemp);
  22.            
  23.             if ((words[1].startsWith(pre) && words[2].startsWith(pre)) || (words[1].endsWith(suf)|| words[2].endsWith(suf)))
  24.             {
  25.                 System.out.println("No");
  26.             }
  27.             else
  28.                 System.out.println("Yes");
  29.         }  
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement