Here is The counting Palindrome.
This program counts the no. of palindrome between two nos. A & B. whith T test cases.In the first line You have to tell the compiler the no. of Test cases
And then Two nos. A & B for every Test Case. for which the compiler counts the palindrome no. in between them.
#include<iostream.h>
int pal(int n)
{
signed int a=n,d,r=0;
while(a)
{
d=a%10;
r=(r*10)+d;
a/=10;
}
if(r==n)
return 1;
else
return 0;
}
int main()
{
signed int T, A, B, count=0, a[10], j=0;
cin>>T;
while(T)
{
cin>>A>>B;
for(signed int i=A;i<=B;++i)
if(pal(i))
count++;
a[j++]=count;
count=0;
--T;
}
for(int m=0;m<j;m++)
cout<<a[m]<<"\n";
}
No comments:
Post a Comment