C-study/06-1/2/loop.c

23 lines
323 B
C
Raw Permalink Normal View History

2021-11-25 06:24:57 +00:00
#include<stdio.h>
int isPalindrome(int n) {
int m = n;
int r = 0;
while (n > 0) {
r = r * 10 + n % 10;
n /= 10;
}
return r == m;
}
int main()
{
int a,b;
scanf("%d %d",&a,&b);
for(int i=a;i<=b;i++){
if(isPalindrome(i)){
printf("%d\n",i);
}
}
return 0;
}