写内容过程,把写内容过程经常用的内容备份一次,如下资料是关于C#利用堆栈进行回文检测的内容,应该能对各朋友有好处。
Console.WriteLine("算法2:请输入一个字符串!");
Queue<char> queue = new Queue<char>();
Stack<char> stack = new Stack<char>();
{
  queue.Enqueue(str2[i]);
  stack.Push(str2[i]);
}

IsHuiWen(queue, stack);

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

 

static void IsHuiWen(Queue<char> queue, Stack<char> stack)
  int i = 0, total = 0;
  bool isHuiWen = true;
  if (queue.Count % 2 == 0)
  total = queue.Count / 2;
  else
  total = queue.Count / 2 + 1;
  while (queue.Count != 0 && stack.Count != 0)
  {
    {
    isHuiWen = false;
    break;
    }
      break;
    ++i;
  }

if (!isHuiWen)
  Console.WriteLine("这不是回文");
else
  Console.WriteLine("这是回文");
}




 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄