如何在后缀树中打印字符串
How to print the string in a suffix tree
我在打印后缀树中最长的公共子字符串时遇到困难。我可以很容易地计算出最长的公共子串的长度,但在实际找到子串时遇到了问题。下面是c++中最长公共子串的代码。有人能帮帮我吗?
添加变量:
int start = -1;
替换:
ans=max(ans,l);
:
if (l > ans) {
ans = l;
start = i;
}
最长的子字符串从b[start]
开始,所以要打印末尾最长的子字符串:
printf("%.*s", ans, b + start);
相关文章:
- C++ |<<运算符重载和打印字符串
- 反向打印字符串
- C++ 用于在数组中打印字符串的随机数
- C 不打印字符串
- 如何在没有同步的情况下使用多个线程(2、4,8、16 个线程)在循环(10,100、1000 个周期)中打印字符串?
- 尝试打印字符串时"Python Exception <class 'gdb.error'> There is no member named _M_dataplus."
- 使用带有 std::cout 的单引号打印字符串实际上打印了数字
- 使用迭代从链表向后打印字符串
- 如何打印字符串而不是数字
- 使用 for 循环打印字符串数组无法正常工作 (C++)
- C++ 打印字符串的内容
- 如何在空格后打印字符串的其余部分
- 如何在C 中打印字符串向量的向量
- 当我打印字符串时,我不知道它是什么输出
- 尝试以随机字符(长读取)打印字符串返回结果
- 从左到右打印字符串的组合(不是排列)c++
- cout 不能一致地打印字符串和变量值,导致输出未对齐
- C++ cout 在擦除换行符后打印字符串不正确
- 从对象数组打印字符串对象
- C++ 粘贴值和打印字符串