C#递归实现回文判断算法
本文实例讲述了C#递归实现回文判断算法,分享给大家供大家参考。具体实现方法如下:
staticvoidMain(string[]args)
{
DateTimedt1=DateTime.Now;
stringtext="abcdedcba"; boolbYes=Recv(text); Console.Write("{0}:{1}回文!",text,bYes?"是":"不是");
DateTimedt2=DateTime.Now; Console.Write("耗时:{0}毫秒",(dt2-dt1).TotalMilliseconds.ToString()); Console.ReadLine(); }
privatestaticboolRecv(stringtext) { stringhead=text.Substring(0,1); stringend=text.Substring(text.Length-1,1); if(head==end) { if(text.Length==1) returntrue; stringt=text.Substring(1,text.Length-2); returnRecv(t); } returnfalse; }
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短