https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/palindromic-numbers-7/submissions/?utm_source=header&utm_medium=search&utm_campaign=he-search
int ispallin(int n)
{
int ar[10],c = 0;
for(;n!=0;n=n/10)
ar[c++] = n%10;
for(int i =0, j= c-1; i<j; i++,j--)
if(ar[i]!=ar[j])
return 0;
return 1;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
scanf("%d%d",&a,&b);
int ans = 0,c=0;;
for(int i=a;i<=b;i++)
if(ispallin(i))
c++;
printf("%d\n",c);
}
return 0;
}
No comments:
Post a Comment