the prefix that solves the given string.
Input format:
Enter an indefinite number of pairs of strings, two per line, separated by a space. For example:
FileName filepath
Tom, Jack.
Output format:
Returns the maximum prefix for two strings, for example:
The common prefix is file
No Common Prefix # # input Sample:
FileName filepath
Tom Jack
Output Sample:
The common prefix is file
No common prefix
Copyright vivi_and_qiao Liwei Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStreamReader;
Import java.util.*;
Import Java.util.Map.Entry;
public class main{public static void prefix (String s1,string s2) {stringbuffer sb=new stringbuffer (); for (int i=0;i< () s1.length () <s2.length () s1.length (): S2.length ()); i++) {if (S1.charat (i) ==s
2.charAt (i)) sb.append (S1.charat (i));
else break;
} if (Sb.length () ==0) System.out.println ("No common prefix");
Else System.out.println ("The common prefix is" +SB);
public static void Main (String []args) throws IOException {/*stringbuffer sb1=new stringbuffer ();
StringBuffer sb2=new StringBuffer ();
Scanner in=new Scanner (system.in);
String s1,s2;
while (In.nextline ()!= "") {S1=in.next (); S2=in.next (); Sb1.append (S1); Sb2.append (S2);
} System.out.println (Sb1.tostring () +sb2.tostring ()); StringBuffer sb1=new StringBuffer ();
StringBuffer sb2=new StringBuffer ();
BufferedReader reader = new BufferedReader (new InputStreamReader (system.in));
do {String line = Reader.readline ();
if (Line.equals ("")) {break;
} int i;
For (I=0;i<line.length (); i++) if (Line.charat (i) = = ") break;
Prefix (line.substring (0, i-1), line.substring (I+1,line.length ()));
} while (true); }
}