Cc performs palindrome detection to determine whether the string is a palindrome

From , 2 Years ago, written in C#, viewed 208 times.
URL https://pastebin.vip/view/9f9e8cba
  1. // --------------- 算法一:根据数组元素----------------------------
  2. Console.WriteLine("算法1:请输入一个字符串!");
  3. string str1 = Console.ReadLine();
  4. StringBuilder a = new StringBuilder();//声明一个可变的字符,用于逆向存放sString里的元素
  5. //逆向存放sString里的元素
  6. for (int i = str1.Length - 1; i >= 0; i--)
  7. {
  8.   a.Append(str1[i]);//循环附加
  9. }
  10.  
  11. if (str1.Equals(a.ToString()))//Equals用于判定两对象是否具有相同值
  12. Console.WriteLine("是回文");
  13. else
  14. Console.WriteLine("不是回文");
  15. //csharp/7216

Reply to "Cc performs palindrome detection to determine whether the string is a palindrome"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website