原字符串中任意一段连续的字符组成的新字符串称为子串,则字符串AAABBBCCC共有多少个不同的非空子串??

同上,谢谢!!!
2025-06-21 20:27:32
推荐回答(1个)
回答1:

--- 给你一个方法 从左边
arrrylist a =new arrylist();
string str=''aaabbbccc'';
for(int i=0 ;i<'aaabbbccc'.lenth;i++)
{
for(int j=i;j<'aaabbbccc'.lenth;j++)
{
string test_str=null;
if(i=j)
{
test_str=str[i].tostring();

///检查该字符串是否存在 如果存在 不添加到 数组中

/// 如果不存在添加到数组中。

}}
else
{
test-str=str。substring(i,j-i+1)
///检查该字符串是否存在 如果存在 不添加到 数组中

/// 如果不存在添加到数组中。

}

}

/// 是否存在
private bool test_exciz( arrylist a,string strs)
{
if(存在)
{
return ture;
}
else
{
return false;
}

}

-- 你在思考下 补充下