#include <iostream>
#include <string>
using namespace std;
int main()
{
string num = "";
bool isPalindrome;
while (cin >> num, num != "0")
{
isPalindrome = true;
for (int i = 0; i < num.length() / 2; ++i) {
if (num[i] != num[num.length() - i - 1]) {
isPalindrome = false;
break;
}
}
if (isPalindrome == true)
cout << "yes" << endl;
else
cout << "no" << endl;
}
return 0;
}
출력에 개행문자 넣어줘야한다.
https://www.acmicpc.net/problem/1259
1259번: 팰린드롬수
입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 1 이상 99999 이하의 정수가 주어진다. 입력의 마지막 줄에는 0이 주어지며, 이 줄은 문제에 포함되지 않는다.
www.acmicpc.net
'알고리즘 공부' 카테고리의 다른 글
백준 10989번 수 정렬하기 3 C++ (0) | 2023.09.11 |
---|---|
백준 2609번 최대공약수와 최소공배수 C++ (0) | 2023.09.11 |
백준 1018번 체스판 다시 칠하기 (0) | 2023.08.21 |
백준 1697번 숨바꼭질 (0) | 2023.03.21 |
백준 7576번 토마토 (0) | 2023.03.16 |