(一)题目描述
编写程序,判断输入的一个字符串是否为回文。若是则输出“Yes”,否则输出“No”。所谓回文是指順读和倒读都是一样的字符串。
输入
abcddcba
输出
Yes
(二)代码
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Judge(Console.ReadLine()));
Console.ReadKey();
}
static String Judge(string str)
{
for (int i = 0; i < str.Length / 2; i++)
{
if (str[i] != str[str.Length - i - 1])
{
return "No";
}
}
return "Yes";
}
}
}