코드
#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라고 하고 빼서 했는데
짝수여도 된다.
그냥 가벼운 구현문제였다.
'하루하나코딩' 카테고리의 다른 글
백준 1920 : 수 찾기 c++ (0) | 2023.03.29 |
---|---|
백준 1436 : 영화감독 숌 c++ (0) | 2023.03.29 |
백준 1085 : 직사각형에서 탈출 (0) | 2023.03.28 |
백준 1018 : 체스판 다시 칠하기 c++ (0) | 2023.03.28 |
Github 업로드 시작 (0) | 2023.03.28 |