Title Link: http://vjudge.net/problem/HDU-1282
I thought a lot when I was doing this topic.
First, how to determine whether a number is a palindrome number (can be expressed in int):
The original idea was to use string processing, with int (log10 () +1) coming in place ... (served himself) ...
Then from the two paragraphs to the middle contrast, all satisfied is palindrome number, and then feel good trouble ah.
Later wrote a function to draw a number in the reverse of the number, to use when the use of an if statement to judge.
Second, the format problem ...
Anyway to do this problem when the brain a little confused, the state is very general, hit water problem.
1#include <cstdio>2#include <cstring>3#include <cmath>4#include <iostream>5#include <algorithm>6#include <string>7#include <cstdlib>8 9 using namespacestd;Ten One intFintN) A { - intnf=0; - while(n) the { -nf=nf*Ten+n%Ten; -N/=Ten; - } + returnNF; - } + A intMain () at { - intn,i,num[ -]; - while(~SCANF ("%d",&N)) - { - intCnt=0; - if(N==f (n)) printf ("0\n%d\n", n); innum[0]=N; - while(n!=f (n)) to { +cnt++; -n+=f (n); thenum[cnt]=N; * } $ if(CNT)Panax Notoginseng { -printf"%d\n", CNT); theprintf"%d", num[0]); + for(i=1; i<=cnt;i++) Aprintf"--->%d", Num[i]); theprintf"\ n"); + } - } $ return 0; $}
(HDU) 1282--palindrome number conjecture