Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int digit(int x)
{
int d=0;
while(x)
{
x/=10;
d++;
}
return d;
}
int main()
{
int a,b,c,d,e,f=0,g,h,i=0,j=0;
scanf("%d", &a);
for(b=1; b<=a; b++)
{
scanf("%d", &c);
d=digit(c);
int ara[d];
while(c)
{
e=c%10;
c/=10;
ara[f]=e;
f++;
}
f=0;
g=d/2;
i=d-1;
for(h=0,j=0; h<g; h++)
{
if(ara[h]==ara[i])
j++;
i--;
}
i=0;
if(j==g)
printf("Case %d: Yes\n",b);
else
printf("Case %d: No\n",b);
}
return 0;
}
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.