c# 判断输入字符串是否回文

来源:互联网 发布:mac python开发环境 编辑:程序博客网 时间:2024/05/16 03:22

回文:

例如 :
txt bccb等

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{    class Program    {                static void Main(string[] args)        {            int nu1, nu2,k;            string str;            k = 0;            str = Console.ReadLine();            for (nu1 = 0, nu2 = str.Length - 1; nu1 <= nu2; nu1++, nu2--)            {                if (str[nu1] != str[nu2])                    k = 1;                break;            }            if (k==0)                Console.WriteLine("yes");            else                Console.WriteLine("no");            Console.ReadKey();        }    }}





原创粉丝点击