Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在打印后缀树中最长的公共子串时遇到困难。我可以轻松计算最长公共子串的长度,但在实际找到子串时遇到问题。下面是 C++ 中最长公共子串的代码。谁能帮忙我出去?
添加变量:
int start = -1;
代替:
ans=max(ans,l);
和:
if (l > ans) { ans = l; start = i; }
最长的子串从 开始b[start],所以最后打印最长的子串:
b[start]
printf("%.*s", ans, b + start);