[恢]hdu 1282

2011-12-16 13:59:48

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1282

题意:中文,不解释。

代码:

# include <stdio.h>


int reverse(int n)
{
int ans = 0 ;
while (n)
{
ans = ans * 10 + n%10 ;
n /= 10 ;
}
return ans ;
}


int calc(int n)
{
int cnt = 0 ;
while(n!=reverse(n))
{
n = n+reverse(n) ;
cnt++ ;
}
return cnt ;
}


int main ()
{
int n ;
while (~scanf ("%d", &n))
{
printf ("%d\n", calc(n)) ;
printf ("%d", n) ;
while (n!=reverse(n))
{
n = n+reverse(n) ;
printf ("--->%d", n) ;
}
printf ("\n") ;
}
return 0 ;
}



posted @ 2012-01-06 17:40  Seraph2012  阅读(176)  评论(0编辑  收藏  举报