using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _404_栈和队列的应用 { class Program { static void Main(string[] args) { string str = Console.ReadLine(); Stack<char> stack = new Stack<char>(); Queue<char> queue = new Queue<char>(); for(int i=0;i<str.Length;i++) { stack.Push(str[i]); queue.Enqueue(str[i]); } bool IsHui = true; while(stack.Count>0) { if(stack.Pop()!=queue.Dequeue()) { IsHui = false; break; } } Console.WriteLine("是否是回文:" + IsHui); Console.ReadKey(); } } }
利用栈和队列判断回文
猜你喜欢
转载自blog.csdn.net/a962035/article/details/79811955
今日推荐
周排行