하루하나코딩
백준 1259 : 팰린드롬수 c++
HAHAKO
2023. 3. 29. 10:46
코드
#include <iostream>
#include <string>
using namespace std;
int main(){
while(true){
string num;
cin >> num;
int cnt = 0;
if(num[0] == '0') break;
for(int i = 0; i < num.length()/2; i++){
if(num[i] != num[num.length()-i-1]){
cout << "no" <<"\n";
break;
}
else cnt++;
}
if(cnt == num.length()/2) cout << "yes" << "\n";
}
return 0;
}
알게된 점
처음에 num의 length가 짝수이면 팰린드롬수가 안될줄알고 그 경우는 no라고 하고 빼서 했는데
짝수여도 된다.
그냥 가벼운 구현문제였다.