The console prints all the "Daffodils"

Source: Internet
Author: User

 

/***//**
* Daffodilnum. Java
* The console prints all "Daffodils", for example, 153 = 1 ^ 3 + 5 ^ 3 + 3 ^ 3
* @ Author codingmouse
* @ Version 0.1
*/

Public class daffodilnum ...{
 
Public static void main (string [] ARGs )...{

// Print method 1:
Int hundreddigit, tendigit, onedigit, Count = 0;

System. Out. println ("the number of all daffodils obtained is :");

For (INT I = 100; I <= 999; I ++ )...{
// Obtain the hundred bits
Hundreddigit = I/100;
// Ten digits
Tendigit = I/10% 10;
// Obtain a single bit
Onedigit = I % 10;

// Determine whether the daffodils are satisfied
If (hundreddigit * hundreddigit +
Tendigit * tendigit +
Onedigit * onedigit = I )...{
// Print the number of daffodils on the console
System. Out. println ("no." ++ count + "the number of daffodils is:" + I );
}
}

}

}

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.