Code: Select all
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
char inverse[15];
unsigned long int inInt,outInt,temp;
int counter,check;
int i=0,j,n;
scanf("%d",&n);
while(i!=n)
{
scanf("%lu",&inInt);
outInt=0;
counter=0;
check=0;
while(inInt!=outInt || check!=1)
{
for(j=0;j<15;j++)
inverse[j]='\0';
temp=inInt+outInt;
inInt=temp;
for(j=0;temp!=0 && j<15;j++)
{
inverse[j]=(char)(temp%10+(int)'0');
temp=temp-temp%10;
temp/=10;
}
puts(inverse);
outInt=(long int)atol(inverse);
if(inInt==outInt)
{
check=1;
break;
}
counter++;
}
printf("%d %lu\n",counter,inInt);
i++;
}
}
i thought two method...but this one didn't work and can't get a.c...
another method is using "inverse long number"...
that's all, and it worked...
this method, i used an array to store inverse number and translate it
to long int number...
and the result should be correct, but it didn't get accepted..
could someome tried to find my bugs..
thanks a million
