For "self-addition of A is executed first and then added, and no other statements are executed when adding this program A", you can't see the statements a++ and b++ in the program. After the addition, the values are still assigned to A and B themselves, not to other variables such as c = a++;+; Z=b++. If you assign values to other variables in this way, it is obvious that the values of C and Z will be the same as those in the textbook. That is to say, the final printf output of this program is the values of A and B, but the values of A and B have changed in the process of self-addition, which is equivalent to the statements A = a++ and B = B++.
I changed your program. You can run two programs, and then compare them to understand why the values of A and B are both 2 and 1 in the end. The procedure is as follows.
# include & ltstdio.h & gt
Master ()
{
int x= 1,y=0,a=0,b=0,c=0,z = 0;
Switch (x)
{Case 1:
Switch (y)
{
Case 0: c = a++; Break;
Case1:b++; Break;
}
Case 2: c=a++, z = b++;+; Break;
Case 3: a++, b++;+;
}
printf("c=%d,z=%d\n ",c,z);
}
What's the difference between ++i and i++?
Simply put: ++i adds the values stored in I and "returns" the added new value to the expression that uses it; And i++ adds 1 to I without increasing the original value.