-
There are two kinds of self-increment and self-reduction, one is the forward fall (++i,--i), and one suffix (i++, i--) There is a big difference between the two, and the prefix self-increment and self-decrease is to run itself first, and then run others. The suffix is self-incrementing and self-decreasing, which is to run the other first in the run itself.
To name two examples:
a=1;a=(a++)a)
The result of the final a is 4;
Analysis, the first a++ is the word that does not run itself first, and the result is 1The latter ++a is to run itself plus plus first, so the result is 2At the end of the result, there must be a self-adding, so the result is 4
a=1;a=(++a)+(a++)
The final result was 5;
Analysis, the first ++a is the self-addition of the run itself, so a=2The value of a in the latter a++ is 2, so the result of addition is 4, and the result of the result must have a self-addition of itself at the end, so the result is 5
a=1;a=(a++)a)+(a++)
The result is 7; Analysis, the first A++ is also a self-addition that does not run itself, and the result is 1The second ++a is to run its own self-additive, so the result is 2The third a++, due to the influence of the second self-addition, the value of a itself also becomes 2.
At the end of the running result, since there are two self-additives, the final result is 7
I believe that through the above three examples, you will know a lot about this self-increase and self-reduction, and the rules of self-reduction are the same as self-addition, so I will not give an example.
-
??***???
Just pay attention to the usage. What***.
-
There is no need to dwell on this kind of problem.
If it is q=(++j)+(j); The result is 7+7=14 continuous addition, and the normal logic should be 3*8=24, but in fact, because of the compiler's optimization, the continuous addition is split into two register operations, which is equivalent to:
int edx = (+j)+(j);
q = edx + j);
This makes 7+7+8=22
It's an optimization issue, and you don't have to dwell on it.
This is the actual mode of operation, and if you understand the assembly, you can understand it.
-
The difference between ++i and i++ is that i increases 1 but ++i and i++ remain unchanged in the calculation process It is worth changing in the calculation process Just do it again.
-
The pre-++ and post-++ of the C language are called the self-increment operator pre- and post-- are called self-decreasing operators, and the following is introduced by the difference between the self-incrementing operators, which are similar to self-decreasing.
If you write the autoincrement operator as a single statement, there is no difference between the two ++i; and i++; Both are assigned to i by i+1, but if the autoincrement operator is written into another expression, the two are very different, for example, i=5;
j=i++;
After execution, i is 6 and j is 5
i=5;j=++i;
After execution, i is 6 and j is 6
-
The use of self-increment or self-decrement in a complete expression is determined by ***. That is to say, the C language does not guarantee the execution order of p=(i++)i++)i++) and the execution order of the three i++s, not necessarily from left to right to execute the three i++ respectively, it may be executed skipping, for example, the three ++j in q are not executed from left to right. However, c guarantees that in a complete expression, the i and j of p and q are incremented three times, that is, the last i and j are both 8, but the values of p and q are not guaranteed.
Therefore, you should avoid using similar association self-incrementing and self-decreasing expressions in your program to avoid unpredictable results.
-
This result is related to the compiler, it doesn't make much sense, and should be avoided as much as possible when programming.
-
Look at this**. The result of P is 14, which should be 13 according to our calculations, but the compiler thinks that the priority in () is the same during the compilation process, and they are all self-incrementing first, so the compiler calculates the two self-increments first, and then it is 7+7.
And the following is the same, the first two are also done at the same time. The latter is 7+7+8, and the last is 22(I've asked before, and the teacher explained it to me with a compiled compilation).
-
Together, why do I count 21
-
a+++4 is equivalent to (a++)4 as many fetch operators as possible from left to right.
First of all, to understand the meaning of self-increment and self-reduction, its function is to add one to the variable, which is not affected by the prefix or suffix.
a++)4=7 a=4
-
The pre-++ and post-++ of the C language are called the pre-increment operator and the post--is called the self-decreasing operator, and the following is introduced by the difference between the self-increasing operator, which is similar to the self-decreasing.
If you write the autoincrement operator as a single statement, there is no difference between the two ++i; and i++; Both are assigned to i by i+1, but if the autoincrement operator is written into another expression, the two are very different, for example, i=5;
j=i++;
After execution, i is 6 and j is 5
i=5;j=++i;
After execution, i is 6 and j is 6
-
++A is the first self-add and then operate, A++ is the first operation and then self-add,-- which is also similar.
A+++4 This kind of question is easy to confuse, and for some operation rules, different compilation systems have different regulations, and it is not recommended for landlords to use it.
If it's an assignment problem, just run it with the program and see what the result is.
-
int a[3];
for(i=0;i<3;) scanf("%d",a[i++]
correct int a[3];
for(i=0;i<3;) scanf("%d",a[++i]);
The subscript is out of bounds. for(i=0;i<3;) scanf("%d",a[i++]
Quite for(i=0; i<3;That is, back.
for(i=0;i<3;i++)scanf("%d",a[i]);
and for(i=0; i<3;) scanf("%d",a[++i]);
Quite for(i=0; i<3;)
So the next answer is out of bounds.
-
The difference between a prefix addition or subtraction and a suffix addition or subtraction is the value in the expression.
In the expression, the prefix should be incremented first, and then used.
In the expression, the prefix is self-subtracted first, and then used.
In the expression , the suffix plus should use the original value first. After the expression is out, it is self-incremented.
In the expression , the original value should be used first for the suffix minus . After the expression is out, it is self-subtracted.
a=++i;The prefix should be self-incremented first, and then used. Execute: i=i+1; a=i ; i=7; a=7;)
b=i++;The suffix plus should use the original value first. After the expression is out, it is self-incremented. Execute b=i; i++;b=7;i=8)
a=--i;Prefix reduction should be self-reduced first, and then used. i=i-1; a=i; (i=7;a=7)
b=i--;Suffix minus to use the original value first, executed. b=; (b=7; i=6)
printf("%d", -i++) suffix plus to use the original value first. After the expression is out, it is self-incremented. print -i; (6) The expression i=i+1 is produced; (i=7)
printf("i=%d",i);Print i=7
-
I wrote it on VC6·0 and here's a screenshot.
First of all, the first two 7s Because i++ is assigned first to add one, ++i is to add one first and then assign the operation, so the value stored in a, b is 7, and the value of i is 8
And then there are the next two 7s, in the same way a is 7, b is 7, i is 6 in this case, in -i++ because the ++ is in the back, so first output -6, and then add i to one, which is i becomes 7
Finally, according to the output format, i=7 was output
-
The first row i is 6 and a and b are garbage values.
The second line A gives a copy of i to self-incrementing, a is 7, and i is 7, and b is assigned to a copy of i, b is 7, and then i is self-incrementing, and i is 8
Print out a is 7 b is 7 at this time i is 8 and then a is given a copy after i is self-subtracted, which is 7, and i is 7 at this time, b is given a copy of i is 7, and i is reduced to 6.
Print again, A is 7, B is 7, and i is 6
According to the priority I++ first, then, if the value of the i++ expression is a copy of i, then it is 6, and then the minus expression is -6. This -6 is passed to printf, and -6 is printed, and i is also self-subtracting, and i is 5 at this time.
Print again, i is 5.
-
b = a++;Assign the value of a to b first, and then add one to the value of a. b = 10,a = 11
b = a--;Assign the value of a to b first, and then subtract the value of a by one. b = 11,a = 10
The first one is 10 and the second one is 11
b = ++a;Add the value of a by one and assign it to b
b = --a;Subtract the value of a by one and assign it to b
-
For example: i=1; i++;It means that when i runs to "i++" on the original basis, it adds 1 by itself, but "i++"."The value of i does not change, and the value of i becomes 2; And in "++i", "+i.""with"i"is equal to 2, and when "+" is replaced by "—", the same goes for ...
-
is the operator of ++, e.g. a++ is equivalent to a = a + 1;This is the same as ,-- simplification, and self-increase and self-reduction are divided into preposition and postposition, the difference is that the preposition is first self-subtraction and then operation, and the latter is the first operation and then self-reduction, for example.
int a = 5;
int b = a++;
At this point b = 5;
and int a = 5;
int b = ++a;
At this point b = 6;
Understand it yourself, its practical habits can be simplified a lot**.
-
Suppose you define an integer variable.
int a=0;
a++;That is, every time it is executed, a is increased by 1, that is, a = a+1 is executed once; Self-reduction is similar.
-
It is an arithmetic operator with a prefix (i) and a suffix (i). The former means that the value is assigned to x and then 1 is added, such as i 2;x i, then the value of x is 2 and the value of i is 3. The latter means that 1 is added first and then assigned to x, such as i 2;x i, then the value of x is 3 and the value of i is 3.
-
You don't understand, self-increase is plus one, self-subtraction is minus one.
a refers to the value of a + 1 and adds one to the value in the operation.
a++ is to participate in the operation first, and then add 1 when it is over
-
i++ means that the value of i is taken first, and then i is incrementing by 1, that is, if another m=i, then the value of i++ is still equal to m, but the actual value of i is m+1.
i means that the auto-increment is performed first, and then the value of i is extracted, that is, ++i is equal to m+1, and i is also equal to m+1
The same goes for self-reduction.
-
i++ is i=i+1
i++ is i=i+1
Others--iah++iah, you don't need to distinguish that each compiler operation is different, and you can't simply put it into the program to calculate.
But if you just look at the logic, it is -- the first is to subtract 1 and then calculate, and the second is to calculate first and then add 1
-
"++ in front means first self-increment and then assigned, ++ in the back means after self-increase, first assigned.
- "In the same way,
-
Look at some more examples.
For example, i++ and ++i;
There is no difference when used as a statement on its own.
When used in conjunction with other statements such as assignment, output, etc.
For example, int a = i++ means that the value of i is assigned to a first, and then i adds int a = ++i is to add i first, and then the value of i is added to a
-
The rules of self-increment and self-decrease are the same, and they are both divided into two types: pre-position and post-position.
The precedent is ++i (or --i), which is the first operation, that is, the first increment of i by 1, and the second operation is the subsequent operation of i.
For example: i=1, y=++i
Then i is a pre-increment operation, so i first increments by 1, i=2, and then the operation on i is to take the value of i and assign it to y, then y=2.
The posterior is i++ (or i--), which is the first operation, that is, the operation of i, and the later operation, that is, the self-increment of i.
For example: i=1, y=++i
Then i is a posterior auto-increment operation, so the first operation is to take the value of i and assign it to y, then y=1, and then auto-increment 1 for i, i=2.
In order to drive the focus and zoom of a DSLR lens, a mechanical motor structure with strong torque is required >>>More
iOS (formerly known as iPhoneOS) is an operating system developed by Apple for the iPhone. It is for iPhone, iPod Touch and iPad. Just like the Mac OS X operating system on which it is based, it is also based on Darwin. >>>More
This depends on how you deal with it, between your own situation has been passive, fortunately your boyfriend is good to you, then you have to cherish it, for him you also have to change your temper, for your happiness, you have to change yourself, let his parents change their opinion of you, try to let them accept you, after all, it is worth it to make a certain effort for love, I hope you can be happy, and I hope that there will be lovers in the world who will eventually become married!
Here's how to manage your employees: Lead by example as a leader. To manage employees well, leaders must first set a good example so that they can be authoritative and persuasive when managing employees. >>>More
1.Develop the ability to think independently.
I like to read, I often discuss the content of the book with my friends, there is also a girl in the dormitory who likes to read, often ask me some questions, after a long time, I found that she reads a bit rigid, how to say, that is, she is easy to accept the views or ideas in the book, when she reads two books, the content is a little contradictory, it will become at a loss. Suppose she reads two books about healthy eating, one says it's healthy to eat fruit before a meal, and the other says that you can stay healthy by eating fruit after a meal. She will keep wondering whether it is better to eat fruit before a meal or after a meal? >>>More