C언어/C언어 문제
[C언어] 백준 1259번: 팰린드롬수
renne
2022. 7. 24. 12:44
https://www.acmicpc.net/problem/1259
1259번: 팰린드롬수
입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 1 이상 99999 이하의 정수가 주어진다. 입력의 마지막 줄에는 0이 주어지며, 이 줄은 문제에 포함되지 않는다.
www.acmicpc.net
#include <stdio.h>
#include <string.h>
int main(){
int len, judge = 1;
char num[6] = {1};
while (1){
scanf("%s", num);
if (num[0] == '0') break;
len = strlen(num);
judge = 1;
for (int i = 0; i < len/2 + 1; i++){
if (num[i] == num[len-1]){
len--;
}
else{
judge = 0;
break;
}
}
if (judge) printf("yes\n");
else printf("no\n");
}
return 0;
}