| Describe |
Topic title: Calculates the length of the maximum common string of two strings, and the characters are case-insensitive Detailed Description: Interface description Prototype: int Getcommonstrlength (char * pfirststr, char * psecondstr); Input parameters: char * pfirststr//First string char * psecondstr//a second string |
| Knowledge points |
String, finding |
| Run time limit |
10M |
| Memory limit |
128 |
| Input |
Enter two strings |
| Output |
Output an integer |
| Sample input |
Asdfas Werasdfaswer |
| Sample output |
6 |
Package Com.oj5;import Java.util.arraylist;import Java.util.list;import Java.util.scanner;public class Oj {public static void Main (string[] args) {Scanner in = new Scanner (system.in); String data = In.nextline (); String[] Tran = Data.split (""); String stra = tran[0]; String StrB = tran[1]; String Dataa = Stra.tolowercase (); String Datab = Strb.tolowercase ();//system.out.println (datab.substring (1, 7)); int max = 0;for (int i = 1; i<=dataa.leng Th (); i++) {//sets the length of the string//system.out.println ("Length:" +i); for (int j = 0;j < Dataa.length (); J + +) {//Set start position int end = J+i>dataa.length ()? Dataa.length (): j+i; String temp = dataa.substring (j, End), if (Datab.contains (temp) && (end-j) >max) {//system.out.println (temp); max = End-j;}}} SYSTEM.OUT.PRINTLN (max);}}
Common string calculations