코딩 공부/C#
[C# / 백준] 10988번 문제 팰린드롬인지 확인하기
통통푸린
2023. 5. 30. 10:41
728x90
반응형
문제
알파벳 소문자로만 이루어진 단어가 주어진다. 이때, 이 단어가 팰린드롬인지 아닌지 확인하는 프로그램을 작성하시오.
팰린드롬이란 앞으로 읽을 때와 거꾸로 읽을 때 똑같은 단어를 말한다.
level, noon은 팰린드롬이고, baekjoon, online, judge는 팰린드롬이 아니다.
입력
첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다.
예제 입력 및 출력
풀이
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
using System.Threading.Channels;
internal class Program
{
private static void Main(string[] args)
{
string str = Console.ReadLine();
string str2 = new string(str.Reverse().ToArray());
// 입력받은 문자열을 뒤집어서 비교
if (str == str2)
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("0");
}
}
}
728x90
반응형