Basic알고리즘/팰린드롬/조현태

느낀점

파이썬은 좋겠다. 코드가 짧아서.ㅋ
씨는 슬퍼..T.T

코드


~cpp
#include <iostream>

using namespace std;

#define TRUE 1
#define FALSE 0

void main()
{
	char buffur[255];
	cin >> buffur;
	int strSize = strlen(buffur);
	int nowCheck = strSize - 1;
	bool isSame = TRUE;
	for (register unsigned int i = 0; i < strSize / 2; ++i)
	{
		//// 한글인가?
		if (0 > buffur[i])
		{
			if (buffur[i] != buffur[nowCheck - 1] || buffur[i + 1] != buffur[nowCheck] )
			{
				isSame = FALSE;
				break;
			}
			++i;
			nowCheck -= 2;
		}
		else
		{
			if (buffur[i] != buffur[nowCheck])
			{
				isSame = FALSE;
				break;
			}
			--nowCheck;
		}
	}
	if (isSame)
		cout << "true" << endl;
	else
		cout << "false" << endl;
}
Retrieved from http://wiki.zeropage.org/wiki.php/Basic알고리즘/팰린드롬/조현태
last modified 2021-02-07 05:22:34