写了一个代码,是解决求最大不含重复字符子字符串的问题的
有兴趣的同仁可以看一看,指出有什么不足的地方
public int Fun(string st) {
int count = st.Length;
int countSum=1;
int sInfo;
int eInfo;
int t;
int s;
for (int i= 0; i < count; i++)
{
for (int j = countSum ; j < count-i+1; j++)
{
string subst = st.Substring(i,j);
char[] charArray = subst.ToCharArray();
#region 判断是否有重复的字符
for (t = 0; t < j - 1; t++)
{
for (s = t +1 ; s < j; s++)
{
if (charArray[t] == charArray[s])
{
break;
}
}
if (s != j)
{
break;
}
}
#endregion
if (t == j-1)//判断是否字符串中的字符都检索了
{
sInfo = i;
eInfo = i+j-1;
countSum = j;
}
else {
break;
}
}
if (countSum +i+1>=count)
{
break;
}
}
return countSum;
}