(HDU) 1282--palindrome number conjecture

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.