C # -- 2nd weekly lab -- Task 6 -- write a console application -- output all the daffodils

Source: Internet
Author: User

/* (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.

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.