/* (Start of program header annotation)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: Output all daffodils
* Author: Lei hengxin
* Completion date: January 1, September 08, 2012
* Version No.: V1.0
* Description of tasks and Solutions
* Input description:
* Problem description:
* Program output:
* End the comment in the program Header
*/
[Csharp]
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Namespace ConsoleApplication_do_while
{
Class Program
{
Static void Main (string [] args)
{
Console. WriteLine ("this is a program that outputs all the Daffodils ");
Int hundred, ten, bits;
For (int I = 100; I <1000; ++ I)
{
Hundred = I/100;
Ten = I % 100/10;
Bits = I % 100% 10; www.2cto.com
If (I = hundred * hundred + ten * ten + bits * bits)
Console. WriteLine ("{0} = {1} ^ 3 + {2} ^ 3 + {3} ^ 3 so {4} is the number of daffodils. ", I, hundred, ten, bits, I );
}
Console. ReadKey ();
}
}
}
Running result:
Experience Accumulation:
1. When bits = I % 100% 10 is calculated as bits = I % 100;
Only 407 of the daffodils are output. It seems that you should pay attention to the details in the future.