首页 > 代码库 > 小算法:递归实现回文判断

小算法:递归实现回文判断

static void Main(string[] args)        {            DateTime dt1 = DateTime.Now;            string text = "abcdedcba";            bool bYes = Recv(text);            Console.Write("{0}:{1}回文!", text, bYes ? "是" : "不是");            DateTime dt2 = DateTime.Now;            Console.Write("耗时:{0}毫秒", (dt2 - dt1).TotalMilliseconds.ToString());            Console.ReadLine();        }        private static bool Recv(string text)        {            string head = text.Substring(0, 1);            string end = text.Substring(text.Length - 1, 1);            if (head == end)            {                if (text.Length == 1)                    return true;                string t = text.Substring(1, text.Length - 2);                return Recv(t);            }            return false;        }

  

小算法:递归实现回文判断