The problem of decreasing and increasing i, the problem of self increasing and self decreasing i

Updated on healthy 2024-04-20
25 answers
  1. Anonymous users2024-02-08

    The first one to be executed is the post-increase and subtraction The result is 4

    The second execution is equivalent to i=i-2, which has no relationship between the increase and decrease, and will be executed directly, and the result is 2.

  2. Anonymous users2024-02-07

    i--: use the original value of i in the expression first, and then put i-1;

    i: The value after using i-1 in the expression.

    i-=2: Equivalent to i=i-2, according to the operator priority, i-2 is calculated first, and then the value is assigned to i, and then output.

  3. Anonymous users2024-02-06

    Pair on the first floor: the first one to be executed is the post-increase or subtraction The result is 4

    The second execution is equivalent to i=i-2, which has no relationship between the increase and decrease, and will be executed directly, and the result is 2.

  4. Anonymous users2024-02-05

    i--(is a reference to and then decrease (increase).)

    i-=2 is equivalent to i = i-2

    So say cout

  5. Anonymous users2024-02-04

    If it's really hard to understand, it's hard to remember.

    i++, i--The so-called posterior (increase or decrease) means that the next sentence is added or subtracted after the current statement is executed. example1:

    int i=4;

    coutint i=4;

    cout<<+i; 5

    cout<<-i; 4

  6. Anonymous users2024-02-03

    It turned out to be 4 1, why didn't I get 4 2?

  7. Anonymous users2024-02-02

    +i is no different from i++ itself, both of which are the value of the variable i plus 1. But it's not the same for expressions. Such as:

    i=1;k=i++;

    j=++i;

    i is to add 1 to the value of variable i first, and then assign the value to j variable (j=3) i++ is to assign the value of variable i to k first, and so on k=i++; After the statement is executed, the value of i is increased by 1. (i.e. use the value first and then add 1) (k=1).

    Note: The value of k is the value of i itself. If you know how to debug, it's best to debug it.

    For example: include

    main()

    int i=1,k,j;

    k=i++;

    j=++i;

    printf("%d %d",k,j);

  8. Anonymous users2024-02-01

    i=9;j=11;m=9;n=10

    You can run it and try it.

    First of all, consider that ++ is higher than = priority, and ++ is lower than + first. Therefore, i first adds to equal to 9, and then assigns a value to m, so m=9; J is assigned to n first, which is equal to 10, and then J is added to 11

  9. Anonymous users2024-01-31

    First paragraph**:

    i is to increase the value of i first, and then use it.

    p=f(i,++i);It is to execute ++i first, and then make a function call. Because after executing ++i, the value of i has become 3, so it is equivalent to p=f(3,3);

    You can print out the values of a and b in the function f, and you will find that both a and b are 3

    Second paragraph**:

    i++ is to use the value of i first, and then add the value of i by 1

    So it is equivalent to executing p=f(2,2) first;

    After execution, change the value of i to 3The answer should be 0

    I suspect that your teacher's courseware is written incorrectly, so I suggest you ask him.

  10. Anonymous users2024-01-30

    The use of self-incrementing or self-decrement expressions as function arguments should be avoided in itself, because different compilation systems do not have uniform methods when computation. For example;

    i=1;c=fun(i,++i);

    When calculated from left to right, it is c=fun(1,2);

    If calculated from right to left, it is c=fun(2,2);

    This kind of problem does not need to be delved into, but the value of the argument should be determined before the function is called, and then the function should be called as an argument.

  11. Anonymous users2024-01-29

    Different compilers get different results, you can try GCC and VC specific principles are now difficult to find on the Internet.

    In the programming specification, it is also clearly stipulated that this form is not allowed to be used for programming.

  12. Anonymous users2024-01-28

    You can output (++i)+(i)+(i) to know that it is equal to 9, why it is equal to 10, it may be the reason why a is not assigned, you first assign a 0 to try.

  13. Anonymous users2024-01-27

    ++i means that i increments first and then participates in the operation.

    i++ means that i participates in the operation first, and then increases automatically.

    If i++ and ++i are in a separate line, then there is no difference between the two (because there is no operation in which i needs to participate).

    Here it is recommended to use i++ instead of i=i+1; This is because ++ was the earliest symbol designed in C to save memory. With so much memory in computers nowadays, there's no need to add trouble to yourself like this.

  14. Anonymous users2024-01-26

    Look at whether ++ is in front of or behind i.

    i is in front of i, which means that before this expression is used, i+1 is given i++ is after i is used, and then i+1

    e.g. a=1;

    b=++a;At this time, b=1, a=2, before assigning a value to b, c=a++; At this time, a=2, c=2; After execution, a=3;

    d=a;//d=3

  15. Anonymous users2024-01-25

    Here's an example:

    i=1;5*(+i)=10

    At this point, i=2;

    i=1;5*(i++)=5;

    At this point, i=2;

  16. Anonymous users2024-01-24

    int n=3

    int i=n++,j=n--;i=3 j=4 n=3 Description: n++ is post++, that is, the value is assigned first and then the operation is performed. So first assign 3 to i, then add 1, so i=3, and then, n becomes 4 at this point.

    n--is the last --, that is: first assign the value and then calculate. So first assign 4 to j and then subtract 1, so j=4 and n=3

    int i=++n, j=--n: i=4 j=3 n=3 Description: ++n is the first ++, that is, the value is calculated first and then assigned, so 3+1 is used first, and then the result 4 is assigned to i. --n is the same as the previous --,, you should understand.

  17. Anonymous users2024-01-23

    int n=3 int i=n++,j=n--;// i=3 j=4,n=3 int i=++n, j=--n: // i=4 j=3 n=3

    int i=n++,j=n--;

    It can be translated into the following statement.

    int i=n;

    n=n+1;

    int j=n;

    n--;int i=++n, j=--n:

    Can be translated as:

    n=n+1;

    int i = n;

    in=n-1;

    j=n;

  18. Anonymous users2024-01-22

    n++ can be understood as n=n+1; So it is i=4, and in the same way n-- is equivalent to n=n-1, so n=2;

    n and --n and n++, n--the result is the same, and I don't know exactly why.

    You can search for the difference between ++i and i++. It seems to be a matter of calculation.

  19. Anonymous users2024-01-21

    C language is operated from left to right, ++ and -- in the front is to add and subtract first and then assign, and in the back is to assign value first and then add and subtract, so the first sentence is i=3, j=4, n=3, and the second sentence is i=4, j=3, n=3

  20. Anonymous users2024-01-20

    1. Used in circulation.

    2. It is used in the assignment.

    3. It is used in timing.

  21. Anonymous users2024-01-19

    The main thing is to see that this variable uses the current value, and after it is used up, it needs to be self-incremented after this step is done.

    For example: int i, j, sum;

    sum = 0;

    for(j=0; j<100;j++)

  22. Anonymous users2024-01-18

    ++, the priority is higher than *, but after the operation of ++, a is to participate in the operation with the current value, and then the actual execution of ++ after the operation is over, so b=1*0*1, the last value of a is 2

    You can understand the order of execution is --a, ++a, *, a++, but it is not recommended that you write such programs, such programs are just to help you understand the priority of operators, and do not use such obscure ** in your own program in order to show that you are very good.

  23. Anonymous users2024-01-17

    The key statement is int b=a++*a++a;

    Because the C++ machine is running, this is counted as a statement! And in this statement, the value of a is all 1, only if; After the end of the sign, the value of a will change, that is, the value of (a++) is 1, the value of (-a) is 0, and the value of (+a) is 2, so b is 0; Remember to think of (a++)a) and (a) as a whole.

  24. Anonymous users2024-01-16

    This result depends on the compiler, and different compilers may have different results, especially if you turn on the compiler's optimization options when compiling, it is very likely that the output result will be 0

  25. Anonymous users2024-01-15

    You tried it with release, but the result was not 0

    If you have other compilers, you'll be pleasantly surprised to find that the results are varied.

Related questions
27 answers2024-04-20

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. >>>More

7 answers2024-04-20

+ Follow the right binding rule;

a=++i++;Equivalent to int temp=i++, a=++temp; >>>More

21 answers2024-04-20

Prefix self-addition and suffix self-addition are different, and prefix self-addition is used after self-adding, such as printf("%d,%d",++d,d);Here, although the calculation time is from right to left, when calculating to ++d, the computer explicitly calculates the value of d first and then uses it, and the suffix self-addition uses the additional one, so printf("%d,%d",c,c++) after the compilation result, the printf function uses a value that is 3, because it is used first, which is the result of the compiler's processing. You can only ask the person who designed the compiler in the first place. >>>More

5 answers2024-04-20

Personally, I don't think it's worth it. It's also the i3 that I just started. I checked a lot of information on the Internet, and the i5 has one more function than the i3, which is the turbo frequency technology. >>>More

9 answers2024-04-20

First of all, a 27-inch screen is necessary, the 27-inch resolution is 2560 1440, and the 1920 1080, a larger screen and higher resolution allow you to open more plug-in windows under the same screen without being affected, longer audio tracks don't have to be dragged around, the convenience is not the same, and the price difference is not much. >>>More