알고리즘

[알고리즘] 백준 10174 - 팰린드롬 (C++)

blueberrysoda 2025. 6. 11. 23:54

[문제 링크] : https://www.acmicpc.net/problem/10174

#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    cin.ignore();

    for(int i=0; i<N; i++){
        string S;
        getline(cin, S);

        transform(S.begin(), S.end(), S.begin(), ::tolower);

        int size = S.length();
        bool flag = true;

        for(int j=0; j<size/2; j++){
            if(S[j] != S[size - j - 1]){
                flag = false;
            }
        }

        if(flag == true){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }

    return 0;
}