首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2013-03-16 
c# 判断输入字符串是否回文回文:例如 :txt bccb等using Systemusing System.Collections.Genericusing S

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

回文:

例如 :
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();        }    }}





热点排行