1 / 3
Sep 2021

#include<stdio.h>
long int rev(long int p);
int main(void)
{
// your code here
long int i,a[100],k,n;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
scanf("%ld",&a[i]);
}
for(i=0;i<n;i++)
{
a[i]++;
k=rev(a[i]);
while((a[i])!=k)
{
a[i]++;
k=rev(a[i]);
}
if(k<11)
{
printf(“11\n”);
}
else
printf("%ld\n",k);
}

return 0;

}
long int rev(long int p)
{
long int i,l=0;
for(i=0;p!=0;p/=10)
{
l=l*10+p%10;
}
return l;
}

  • created

    Sep '21
  • last reply

    Oct '21
  • 2

    replies

  • 628

    views

  • 3

    users

I don’t understand,
why did you not paste the code into the subject of your message!? :wink:

21 days later

You’ve misread the limits. The number can be up to 1 million digits long - it won’t fit into a long int, and you’ll need to reconsider.

Suggested Topics

Want to read more? Browse other topics in Online Judge System or view latest topics.