#include<bits/stdc++.h> #include<string> using namespace std; int main() { string x,y; while(cin>>x>>y) { //以下开始,先把较短的子串赋值给a,题目有要求,如果有多个, //需要输出较短子串中先出现的那个 string a,b;//a为较短字符串 if(x.size()<=y.size()) { a=x;b=y; } else { a=y;b=x; } //以下才开始找公共子串 int m,n,tmp; vector<char> v1,v2; for(int i=0;i<a.size();i++) for(int j=0;j<b.size();j++) { m=i;n=j; while(a[m]==b[n]) { v2.push_back(a[m]); if(m<(a.size()-1)&&n<(b.size()-1)) { m++;n++; } else break; } if(v1.size()<v2.size()) v1=v2; v2.clear(); } for(auto x:v1) cout<<x; cout<<endl; } }