[C#] C#进行回文检测的代码3 →→→→→进入此内容的聊天室

来自 , 2021-04-25, 写在 C#, 查看 147 次.
URL http://www.code666.cn/view/fc452d06
  1. //--------------------------算法三:-----------
  2.  
  3. Console.WriteLine("算法3:请输入一个字符串!");
  4. string str3 = Console.ReadLine();
  5. string s=null;
  6. //将str3压入栈中
  7. for (int i = 0; i < str3.Length; ++i)
  8. {
  9.   stack.Push(str3[i]);
  10. }
  11. //循环将栈元素放入s中
  12. while (stack.Count>0)
  13. {
  14.   s +=stack.Pop().ToString();
  15. }
  16.  
  17. if (str3!= s)
  18. {
  19.   Console.WriteLine("这不是回文");
  20. }
  21. else{ Console.WriteLine("这是回文");}
  22.   Console.ReadLine();
  23. //csharp/7218

回复 "C#进行回文检测的代码3"

这儿你可以回复上面这条便签

captcha