方法1:python

while True:
    try:
        a = input()
        b = input()
        str_max = 0

        for i in range(len(a)):
            for ii in range(len(b)):
                num = 0
                if a[i] == b[ii]:
                    for n in range(min(len(a) - i, len(b) - ii)):
                        if a[i + n] == b[ii + n]:
                            num += 1
                        else:
                            break
                    if str_max < num:
                        str_max = num

        print(str_max)
    except:
        break

方法2:python
搬砖

while True:
    try:
        a = input()
        b = input()
        if len(a) > len(b):
            a,b = b,a
        max_length = 0
        i = 0
        while i + max_length < len(a):
            while i + max_length < len(a) and a[i:i + max_length + 1] in b:
                max_length += 1
            i += 1
        print(max_length)
    except:
        break

方法3:python
板砖

while True:
    try:
        a = input().upper()
        b = input().upper()
        n = 0
        for i in range(len(a)):
            if a[i-n:i+1] in b:
                n += 1
        print(n)
    except:
        break