백준/C#

[C#] 백준 10988번 : 팰린드롬인지 확인하기

joungdev 2025. 2. 6. 17:09

[C#] 백준 10988번 : 팰린드롬인지 확인하기

using System;

class Program
{
    static void Main()
    {
        string word = Console.ReadLine();
        int b = word.Length - 1;
        bool flag = true;

        for (int i = 0; i < word.Length; i++)
        {
            if (word[i] != word[b])
            {
                Console.WriteLine("0");
                flag = false;
                break;
            }

            b--;
        }

        if (flag)
        {
            Console.WriteLine("1");
        }
    }
}

 

반응형