Home > Back-end > The three procedures of break how understanding
The three procedures of break how understanding
Time:10-02
Use Microsoft visualc++ 2010. The program is checked, baidu, etc., but still can't solve, but understand more and more chaos, Problem a: the result is output, nothing why #include #include Int main (void) { int i,j; for(i=0; i<4. + + I) For (j=1; j<4. + + j) { break; Printf (" aaa \ n "); } System (" pause ") } Question 2: why is the output of the four lines aaa Int main (void) { int i,j; for(i=0; i<4. + + I) For (j=1; j<4. + + j) { Printf (" aaa \ n "); break; } System (" pause "); } Question 3: the program is proved that any one greater than 6 even number can be expressed as the sum of two prime Numbers, why {printf (" % d=% d + % d \ n ", a, m, a - m); break; } as the if (flag==1) break; Printf (" % d=% d + % d \ n ", a, m, a - m); Still stood
#include #include Void main () { Int a, b, c, m, flag. The scanf (" % d ", & amp; A); For (m=2; M{ flag=1; For (b=2; B{if (m % b==0) flag=0; } If (flag==1) For (c=2; C{if ((a - m) % c==0) flag=0; } If (flag==1) {printf (" % d=% d + % d \ n ", a, m, a - m); break; } } System (" pause "); }
CodePudding user response:
1. Did you break, won't execute printf. 2. The second loop to print once you break the second loop execute only once.
CodePudding user response:
The third one didn't understand the problem
CodePudding user response:
If (flag==1) {printf (" % d=% d + % d \ n ", a, m, a - m); break; } to If (flag==1) break; Printf (" % d=% d % d \ n ", a, m, a - m ");