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();
}
}
}
利用栈和队列判断回文
最新推荐文章于 2023-10-17 23:27:25 发布