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