小编val*_*abu的帖子

在不使用字符串函数且不在C#中使用循环语句的情况下检查字符串是否为回文结构

在不使用字符串函数且不在C#中使用循环语句的情况下检查字符串是否为回文结构.我可以没有字符串函数,但我不知道如何没有循环语句检查.我在一次采访中面对这个问题.

using System;
namespace palindrome
{
    class Program
    {
        static void Main(string[] args)
        {
            string s,revs="";
            Console.WriteLine(" Enter string");
            s = Console.ReadLine();
            for (int i = s.Length-1; i >=0; i--) //**i want to replace this for loop**
            {
                revs += s[i].ToString();
            }
            if (revs == s) // Checking whether string is palindrome or not
            {
                Console.WriteLine("String is Palindrome \n Entered String Was {0} and reverse string is {1}", s, revs);
            }
            else
            {
                Console.WriteLine("String is not Palindrome \n Entered String …
Run Code Online (Sandbox Code Playgroud)

c# arrays console-application string-function

1
推荐指数
1
解决办法
4787
查看次数

标签 统计

arrays ×1

c# ×1

console-application ×1

string-function ×1