
Simple Array Manipulation
By: a guest on
Dec 27th, 2012 | syntax:
Java | size: 0.74 KB | hits: 38 | expires: Never
import java.util.*;
public class ccc04s1
{
public static void main (String[] args)
{
Scanner str = new Scanner(System.in);
int counter = Integer.parseInt(str.next());
for (int i = 0; i <= counter; i++)
{
String [] words = new String [3];
for (int j = 0; j <=2; j++)
{
words [j] = str.nextLine();
}
char pretemp = words[0].charAt(0);
char suftemp = words[0].charAt(words[0].length()-1);
String pre = Character.toString(pretemp);
String suf = Character.toString(suftemp);
if ((words[1].startsWith(pre) && words[2].startsWith(pre)) || (words[1].endsWith(suf)|| words[2].endsWith(suf)))
{
System.out.println("No");
}
else
System.out.println("Yes");
}
}
}