Number of three daffodils

Source: Internet
Author: User

1#include <stdio.h>2#include <math.h>3 4 5 intMain ()6 {7     /*number of three daffodils8 Concept: If three-digit ABC satisfies abc=a^3+b^3+c^3, it is called three-bit narcissus number. For example 153=1^3+5^3+3^3, so 153 is the number of daffodils9 Ten implementation steps: One 1. Enter two numbers, indicating the interval [a, a], since the solution is three-bit narcissus number, so a>=100,b<=999, and B>a A 2. Implement the algorithm, set NUM, break down the hundred, 10 bits, and then add each three times to see if and equal to Num - 3. Output Narcissus number -  the here we need to introduce a method pow (int x,int y) to include the MATH.H header file - Example: - double x=2.0,y=3.0; - printf ("The%lf of the%LF is:%lf\n", X,y,pow (x, y)); + Print out: 2.000000 of 3 times is: 8.000000 -     */ +      A     //1 Statement hundred 10 digit digit at     intBai,shi,ge; -     intnum; -  -     //2 Implementation Algorithm -      for(num= -; num<=999; num++) -     { in         //2.1 Hundred, 10 bits, single digit decomposition -Bai = num/ -; toShi = num/Ten%Ten; +GE = num%Ten; -         //2.2 Judgment Algorithm the         if(num = Pow (bai,3) +pow (Shi,3) +pow (GE,3)) *         { $printf"%d\n", num);Panax Notoginseng         } -     } the  +     return 0; A}

Printing results:

The concept of the number of daffodils added:

Narcissus number refers to an n-digit number (n≥3), and the sum of the number of its digits on each bit is equal to its own.

Number of three daffodils

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.