본문 바로가기
CodingTest/백준

[c++] 백준 - 1259번: 팰린드롬수

by Daybreak21 2023. 5. 31.

1259번: 팰린드롬수 (acmicpc.net)

 

1259번: 팰린드롬수

입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 1 이상 99999 이하의 정수가 주어진다. 입력의 마지막 줄에는 0이 주어지며, 이 줄은 문제에 포함되지 않는다.

www.acmicpc.net

#include <iostream>
#include <cstring>
using namespace std;

int main() {
	while (1) {
		string word; bool Pal = 1;
		cin >> word; if (word == "0") break;

		for (int i = 0; i < word.size() / 2; i++) 
			if (word[i] != word[word.size()-1 - i]) Pal = 0;
		cout << (Pal ? "yes" : "no") << endl;
	}
	return 0;
}

yes를 yse로 적어놓고 제출5번함; ㅋ 엣쿵~~