求两个字符串最长公共字串
#include<iostream>
#include<string>
using namespace std;
int main() {
string a, b;
while (cin >> a >> b) {
if (b.size() < a.size()) {
swap(a, b);
}
string str_max="";
for (int i = 0; i < a.size(); i++) {
for (int j = a.size()-1; j >=i; j--) {
string tmp = a.substr(i, j - i + 1);
if (int(b.find(tmp)) >= 0) {
if (str_max.size() < tmp.size()) {
str_max = tmp;
}
}
}
}
cout << str_max << endl;
}
}