C # The number of daffodils to ask!

Source: Internet
Author: User

Recently in the introductory study. NET programming, slowly learn some doorway, but also need to learn the dots drip down, today I think of myself, the number of daffodils to write out the code, run also passed, posted here, share to everyone, also to do a record.

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;

Namespace ConsoleApplication10
{
Class Program
{
static void Main (string[] args)
{
for (int i=100;i<1000;i++)//100-1000 within the loop.
{
int hundred = i/100; Find out the number of hundred
int ten = (i-hundred * 100)/10; Find out 10-digit numbers
int gewei = i-hundred*100-ten*10; Find the single digit

int Shuixianhua=hundred*hundred*hundred+ten*ten*ten+gewei*gewei*gewei; Defines the addition of individual bits.

if (Shuixianhua ==i)//If the number of daffodils is equal to our number of cycles
{
Console.WriteLine ("Narcissus number {0}", i); So this number is the number of daffodils, print out the number of daffodils

}
}
Console.readkey (); Wait for any characters to enter

}
}


We ran the results:

??

C # The number of daffodils to ask!

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.