Nine degrees oj--q1168

Source: Internet
Author: User

Import Java.util.Scanner;

public class Q1168 {

public static void Main (string[] args) {

Scanner Scanner = new Scanner (system.in);

String shtstr = Scanner.nextline ();
Char[] C = Shtstr.tochararray ();

while (Scanner.hasnext ()) {

String target = Scanner.nextline ();
String[] s = Target.split ("");
String a = "";
for (int i=0; i<s.length; i++) {

A = A.concat (S[i]);

}

char[] t = A.tochararray ();

for (int i=0; i<t.length; i++) {

J record the length that has been matched (compared to c.length), flag=0 always matches
Int j = 0, flag = 0;
int sig = 0;//record How many characters are matched consecutively
while (true) {

if ((int) c[j]>=65 && (int) c[j]<=90) {
Matches the characters in the short string to A~z
if ((int) T[i+sig] = = (int) C[j] | | (int) T[i] = = (int) c[j]+32) {
Successful match
Flag = 0;
sig++;
j + +;
if (sig = = C.length) {
i = i + sig-1;
Break
}
else if (I+sig = = t.length) {
Not finished, but the character array has been matched to the last one
for (int x=i; x<i+sig; x + +) {
System.out.print (T[x]);
}
i = t.length-1;
Break
}
Elsecontinue;
}
else{
No match succeeded
flag = 1;
for (int x=i; x<=i+sig; x + +) {
System.out.print (T[x]);
}
i = i + sig;
Break
}
}
else if ((int) c[j]>=48 && (int) c[j]<=57) {
Matches the characters in the short string to 0~9
if ((int) T[i+sig] = = (int) c[j]) {
Successful match
Flag = 0;
sig++;
j + +;
if (sig = = C.length) {
i = i + sig-1;
Break
}
else if (I+sig = = t.length) {
Not finished, but the character array has been matched to the last one
for (int x=i; x<i+sig; x + +) {
System.out.print (T[x]);
}
i = t.length-1;
Break
}
Elsecontinue;
}
else{
No match succeeded
flag = 1;
for (int x=i; x<=i+sig; x + +) {
System.out.print (T[x]);
}
i = i + sig;
Break
}
}
else if ((int) c[j]>=97 && (int) c[j]<=122) {
Matches the characters in the short string to A~z
if ((int) T[i+sig] = = (int) C[j] | | (int) T[i+sig] = = (int) c[j]-32) {
Successful match
Flag = 0;
sig++;
j + +;
if (sig = = C.length) {
i = i + sig-1;
Break
}
else if (I+sig = = t.length) {
Not finished, but the character array has been matched to the last one
for (int x=i; x<i+sig; x + +) {
System.out.print (T[x]);
}
i = t.length-1;
Break
}
Elsecontinue;
}
else{
No match succeeded
flag = 1;
for (int x=i; x<=i+sig; x + +) {
System.out.print (T[x]);
}
i = i + sig;
Break
}
}
else {
Match to a different character
if ((int) T[i+sig] = = (int) c[j]) {
Successful match
Flag = 0;
sig++;
j + +;
if (sig = = C.length) {
i = i + sig-1;
Break
}
else if (I+sig = = t.length) {
Not finished, but the character array has been matched to the last one
for (int x=i; x<i+sig; x + +) {
System.out.print (T[x]);
}
i = t.length-1;
Break
}
Elsecontinue;
}
else{
No match succeeded
flag = 1;
for (int x=i; x<=i+sig; x + +) {
System.out.print (T[x]);
}
i = i + sig;
Break
}
}
}
}
System.out.println ();
}

}

}

Nine degrees oj--q1168

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.