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!