1319: the same word formation

Two strings by the same letter (not number of letters, etc.), compared with the word formation. Such as "ab" and "ababbb" "abbbc" and "abcc"  
The first line has an integer N denotes N sets of test data. 
Then there are N rows, and each row has two strings (all lowercase letters and a length less than 10000). 
N output lines. If the two strings is the same word-building output "Yes", otherwise a "No".
2
ab ababbb
abc aac

 

 

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		//TODO
		   String s1[]=new String[1000];
        String s2[]=new String[1000];
        String s3[]=new String[1000];
        int n;
        n=cin.nextInt();

        for (int i = 0; i < n; i++) {
            s1[i]=cin.next();
            s2[i]=cin.next();
        }
        for (int i = 0; i < n; i++) {

            if (s2[i].contains(s1[i]))
                s3[i]="Yes";
            else
                s3[i]="No";
        }

        for (int i = 0; i <n ; i++) {
            System.out.println(s3[i]);
        }

		cin.close();
	}
}

  

Guess you like

Origin www.cnblogs.com/PerZhu/p/11593679.html