C Language Classics The law question asks 100-999 "Narcissus number _c language

Source: Internet
Author: User
Tags pow

title : Print out all the "Narcissus number", the so-called "Narcissus number" refers to a three-digit number, 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.

The implementation code is as follows

#include <iostream> 
#include <Cmath> 
using namespace std; 
* * 
Find the number of daffodils between 100-999 
/int main () 
  int number,hun,ten,gw,sum; 
  for (Number=100;number<1000;++number) { 
    Sum=pow (hun,3) +pow (ten,3) +pow (gw,3); 
    if (Sum==number) 
      //is narcissus number 
      cout<<number<< "is narcissus number" <<endl; 
  return 0; 

Run results

The above is the entire content of this article, I hope to help you learn.

Related Article

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.