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 ");

CodePudding user response:

refer to the second floor ggglivw response:
the third didn't understand the problem

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 "); Why are established

CodePudding user response:

My results are different, I don't know how much is your input, I with a 100. A print VS a lot of print

CodePudding user response:

reference 5 floor ggglivw reply:
my results, I don't know how much is your input, I with a 100. A print VS a lot of print

The input is 12

CodePudding user response:

refer to 6th floor qq_45996839 response:
Quote: refer to the 5 floor ggglivw response:
my results, I don't know how much is your input, I with a 100. A print VS a lot of print

The input is 12

12=5 + 7

CodePudding user response:

Program performance inconsistency that your code has a problem, continue to debug.

CodePudding user response:

Are you sure??? I type 12 a print of a line, a printed line 3??????

CodePudding user response:

I'll under debugging

CodePudding user response:

references 9 f ggglivw response:
are you sure??????? I type 12 a print of a line, a printed line 3??????

Now is learning c + +, have recommended books,

CodePudding user response:

Is your textbook to go, how debugging code, your three questions are simple, himself a debugging can found the problem,

CodePudding user response:

refer to 12 floor ggglivw reply:
is your textbook to go, how debugging code, you are the three questions are simple, own a debugging can find problems,

Thank you for your guidance (* °?=3 °)
  • Related