근본없는 코딩

[C++] 백준10988 팰린드롬인지 확인하기 본문

✔ Online Judge

[C++] 백준10988 팰린드롬인지 확인하기

근본없는 개발자 2023. 6. 29. 23:53

#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	char str[101];
	int len=0;
	cin >> str;
	for (int i = 0; i < 101; i++) {
		if (str[i] == '\0') break;
		else len++;
	}

	for (int i = 0; i < len / 2; i++) {
		if (str[i] != str[len - 1 - i]) {
			cout << 0 << '\n';
			return 0;
		}
	}
	cout << 1 << '\n';
	return 0;
}