字符串位移包含

        static void Main()
        {
            Console.WriteLine(strMove("aabcd","cdaa")); //cdaa 包含 aabcd位移中
        }

        /// <summary>
        /// 字符串位移包含
        /// </summary>
        /// <param name="p_str_src"></param>
        /// <param name="p_str_des"></param>
        /// <returns></returns>
        static bool strMove(string p_str_src,string p_str_des)
        {
            string src = p_str_src;
            string des = p_str_des;

            int len = src.Length;
            for (int i = 0; i < len;i++)
            {
                string temp = src.Substring(0, 1);
                string temp2 = src.Substring(1);
                string newSrc = temp2 + temp;
                src = newSrc;
                if (src.IndexOf(des) > 0)
                {
                    return true;
                }
            }

           return false;
        }

posted on 2009-01-12 21:50  感動常在  阅读(358)  评论(0编辑  收藏  举报