不知道,这样是你想要的么,,不过我是用.net写的.
       private static int START_INDEX = 0;
        private void button1_Click(object sender, EventArgs e)
        {
            char[] t={'a','b','a','b','c','a','b','c','a','c','b','a','b','c','a','c','b','b','a','a','c','c','a','b','c','c','a','a'};
            char[] p = { 'a', 'b', 'c', 'a', 'c' };
            int result = 0;
            int total = t.Length -1;
            bool val = false;
            
            Compare(t, p, 0, 0, ref result, ref total);
            if (result == 5)
            {
                val = true;
            }
            MessageBox.Show(val.ToString() + " StartIndex: " + START_INDEX.ToString());
        }
        private void Compare(char[] t, char[] p, int index, int target, ref int result, ref int total)
        {
            if (index == total) return;
            if (result == 5) return;
            
            if (t[index] == p[target])
            {
                if (START_INDEX == 0)
                    START_INDEX = index;
                
                result = result + 1;
                Compare(t, p, index + 1, target + 1, ref result , ref total);
            }
            else
            {
                START_INDEX = 0;
                result = 0;
                Compare(t, p, index + 1, 0, ref result, ref total);
            }
        }