首页 > 其他 > 详细

堆栈和队列

时间:2017-11-16 10:23:40      阅读:214      评论:0      收藏:0      [点我收藏+]

[Serializable]
[ComVisible(true)]
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(Stack.StackDebugView))]
public class Stack : ICollection, IEnumerable, ICloneable
{}

堆栈 判断回文数

技术分享
        static void Main(string[] args)
        {
            string str = "abcba";
            bool flag = true;
            //for (int i = 0; i <= str.Length/2; i++)
            //{
            //    if (str[i]!=str[str.Length-1-i])
            //    {
            //        flag = false;
            //    }
            //}
           
            Stack list = new Stack();
            string ch;
            for (int i = 0; i < str.Length; i++)
            {
                list.Push(str[i]);
            }
            int pos = 0;
            while(list.Count>0)
            {
                ch = list.Pop().ToString();
                if (ch!=str.Substring(pos,1))
                {
                    flag = false;
                    break;
                }
                pos++;
            }
            Console.WriteLine(flag);
            Console.ReadLine();
        }
View Code

 

堆栈和队列

原文:http://www.cnblogs.com/futengsheng/p/7842830.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!