static void Main(string[] args)
{
Console.WriteLine(“请输入文字:”);
string a = Console.ReadLine();
int flag = 0;
int i = 0;
int j = a.Length - 1;
while(i<=j){
if (a.Substring(i, 1) == a.Substring(j, 1))
{
i++;
j–;
}
else flag=1;
break;
}
if (flag == 0){
Console.WriteLine(“是回文”);
}
else
Console.WriteLine(“不是回文”);
Console.ReadKey();
}
C#判断是不是回文
最新推荐文章于 2023-04-16 01:59:28 发布