一个小程序,调试下结果
namespace 串匹配{
class Program
{
static void Main(string[] args)
{
public int index()
{
string[] A = new[] {"ababcabcacbab" };
string[] B = new[] { "abcac" };
int i=0, j=0;
foreach(string str in A)
{Console.WriteLine(A[str]);}
foreach (string str in B)
{Console.WriteLine(B[str]);}
while (i < A.Length && j < B.Length)
{
if (A[i] == B[j]) { i++; j++; }
else { i = i - j + 2; j = 0; }
}
if (j >= B.Length)
return i - B.Length;
else return 0;
Console.Read();
}
}
}
}
i=5! 高手改正一下