백준/기타

1259번: 팰린드롬수 [C++]

Koalitsiya 2023. 4. 6. 15:28

문제

 

 

풀이

문자열을 뒤집어서 뒤집기 전 문자열과 동일한지 판별하면 된다.

#include <iostream>

using namespace std;

int main() {
	string s1, s2;

	while (true) {
		cin >> s1;

		if (s1 == "0") break;

		for (int i = 0; i < s1.length(); i++)
			s2 += s1[s1.length() - i - 1];

		if (s1 == s2) cout << "yes\n";
		else cout << "no\n";

		s2.clear();
	}

	return 0;
}