"C Language and program design" loop nesting be sure to pay attention to the initialization of variables

Source: Internet
Author: User

Problem Description: To satisfy the condition n=a!+b!+c! all three-digit n and output, wherein the A,B,C is N of the Hundred, ten, single digit.

1#include"stdafx.h"2 3 intMain ()4 {5     intI, J, N,m, SUM (0), prod (1);6      for(i =1; i< +; i++)7     {8n = i;//where it's easy to ignore.9sum =0;//where it's easy to ignore.Ten          for(;1;) One         { Am = n%Ten; -  -              for(j =1; J <= M; J + +) the             { -Prod *=J; -             } -  +Sum + =prod; -Prod =1; +  A             if(N/Ten==0) at             { -                  Break; -             } -  -N/=Ten;//The relative position of the termination condition and the change factor is very important, and the Continue/break statement can make the configuration of the two very flexible -         } in  -         if(i = =sum) to         { +printf"%d\n", i); -         } the     } *  $     return 0;Panax Notoginseng}

Feelings:

The relative position of the termination condition and the change factor is very important, and the Continue/break statement can make the configuration of the two very flexible .

=

"C Language and program design" loop nesting be sure to pay attention to the initialization of variables

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.