Write a program to find out the number of daffodils between 100~999

Source: Internet
Author: User

If a 3-digit number equals the cubic sum of its members, it is called the number of daffodils.

For example, so 407 is a number of daffodils, write a program to find out all the number of daffodils between 100~999.

1#include <stdio.h>2#include <stdlib.h>3 //to determine the number of daffodils, is to return 14 intIsnarcissus (intn);5 6 intMain ()7 {8     inti;9      for(i = -; I < +; i++)Ten         if(Isnarcissus (i)) Oneprintf"%4d", i); Aprintf"\ n"); -  -System"Pause"); the     return 0; - } - //determines whether n is a daffodil number, or returns 1, otherwise returns 0 - intIsnarcissus (intN) + { -     intsum =0;//Record cubes and +     inttemp = n;//Staging this number A      while(Temp >0) at     { -sum = sum + (temp%Ten) * (temp%Ten) * (temp%Ten); -Temp/=Ten; -     } -     if(Sum = =N) -         return 1; in     Else -         return 0; to}

Write a program to find out the number of daffodils between 100~999

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.