本文介绍了运算符优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于int a = 5,为什么a ++ * ++ a = 36因为*从左到右行为而++ a pre -increments a所以我们应该有5x7 = 35。我的书都说++优先于*。

For int a=5, why does a++ * ++a = 36 because * acts left-to-right and ++a pre-increments a so we should have 5x7=35. My books all say that ++ has precedence over *.

推荐答案



我不完全确定,但是++只会在语句结束后递增,而++ a会在语句之前递增a。


所以,既然我们在声明中有++ a,a = 6

所以a ++ * ++ a = 36


并在该语句之后,a = 7.

I''m not entirely sure, but a++ will only increment after the end of the statement, while ++a will increment a before the statement.

So, since we have ++a in the statement, a = 6

so a++ * ++a = 36

and after that statement, a = 7.




这篇关于运算符优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 00:47