백준 1259 c++

magicdrill·2024년 3월 7일
0

백준 문제풀이

목록 보기
110/655

백준 1259 c++

정수를 문자열로 바꾸어 펠린드롬인지 확인하는 간단한 문제다.
결국 1753번 문제를 못 풀었다.

#include <iostream>
#include <string>

using namespace std;

void find_answer(int temp)
{
	string str = to_string(temp);
	int len = str.length();
	int i;

	for (i = 0; i < len / 2; i++)
	{
		if (str[i] == str[len - 1 - i])
		{
			;
		}
		else
		{
			cout << "no\n";
			return;
		}
	}
	cout << "yes\n";

	return;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int temp;

	while (1)
	{
		cin >> temp;
		if (temp == 0)
		{
			break;
		}
		find_answer(temp);
	}

	return 0;
}

0개의 댓글