[BOJ] 10174번: 팰린드롬

김주원·2020년 8월 1일
0
post-thumbnail

문제 링크

https://www.acmicpc.net/problem/10174

코드

C++

#include <iostream>
#include <string>
#include <cctype>
#define endl '\n'

using namespace std;
string str;

int n;
bool isPalindrome() {
	int a = 0, b = str.size() - 1;
	while (a <= b) {
		if (toupper(str[a]) != toupper(str[b]))
			return false;
		a++;
		b--;
	}
	return true;
}

int main() {
	cin >> n;
	cin.ignore(64, '\n');

	for (int i = 0; i < n; i++) {
		getline(cin, str);
		if (isPalindrome())
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	
	return 0;
}
profile
자기계발 블로그

0개의 댓글