在网上看到一篇博客解释的很清楚
C++中substr函数的用法 - GGBeng - 博客园 (cnblogs.com)
#include#include using namespace std; int main() { string s("12345asdf"); string a = s.substr(0,5); //获得字符串s中从第0位开始的长度为5的字符串 cout << a << endl; }
具体应用
不同字串题目描述
一个字符串的非空子串是指字符串中长度至少为 11 的连续的一段字符组成的串。例如,字符串 aaab有非空子串 a, b, aa, ab, aaa, aab, aaab一共 7 个。
注意在计算时,只算本质不同的串的个数。
请问,字符串 01001100010100010100110001010001 有多少个不同的非空子串?
运行限制
最大运行时间:1s最大运行内存: 128M
#include#include #include using namespace std; int main() { string s="0100110001010001"; set se; for(int i=0;i



