#define T(x,y,r) x*r*y/4
main()
{int a=1,b=3,c=5,s1,s2;
s1=MIN(a=b,b-a);
s2=T(a++,a*++b,a+b+c);
printf("%d\n",s1);
printf("%d\n",s2);
}
这个程序s2为什么等于28,请大虾们具体解释一下
不要写这样的程序。这样的代码是错误的。参看The C Programming Language:
Function calls, nested assignment statements, and increment and
decrement operators cause "side effects" - some variable is changed as
a by-product of the evaluation of an expression. In any expression
involving side effects, there can be subtle dependencies on the order
in which variables taking part in the expression are updated. One
unhappy situation is typified by the statement
a[i] = i++;
The question is whether the subscript is the old value of i or the
new. Compilers can interpret this in different ways, and generate
different answers depending on their interpretation. The standard
intentionally leaves most such matters unspecified. When side effects
(assignment to variables) take place within an expression is left to
the discretion of the compiler, since the best order depends strongly
on machine architecture. (The standard does specify that all side
effects on arguments take effect before a function is called, but that
would not help in the call to printf above.)
这是我老师告诉我的答案,我英语也不好,哪位能翻译一下