Output 100-1000 of all the "Narcissus count"

Source: Internet
Author: User
Tags printf

See the full set of "C language problem sets"

Topic:

Print out all the "Narcissus number", the so-called "Narcissus number" refers to a three-digit, its members of the digital cubic and equal to the number itself. For example: 153 is a "narcissus number", because the 153=1 three times side +5 of three times +3 of the three times side.

1. Procedure Analysis:

Use for loop control 100-999 number, each number is decomposed into single-digit, 10 bits, hundred.

2. Program Source code:

#include "stdio.h"
#include "conio.h"
Main ()
{
int i,j,k,n;
printf ("' Water Flower ' number is:");
for (n=100;n<1000;n++)
{
i=n/100;/* decomposition of the Hundred * *
j=n/10%10;/* decomposition of 10-bit * *
k=n%10;/* decomposition out of a bit * *
if (i*100+j*10+k==i*i*i+j*j*j+k*k*k)
printf ("%-5d", N);
}
Getch ();
}

3.Visual C + + 6.0 debugging pass, as shown in figure:

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.