INT B = 0,A = 1; B = + A + ++中;什么是b的值?什么是它的计算? [英] int b=0,a=1;b= ++a + ++a; what is the value of b? what is the calculation for it?
本文介绍了INT B = 0,A = 1; B = + A + ++中;什么是b的值?什么是它的计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
INT的main()
{
INT B = 0,A = 1; //初始化a和b
B = + A + + + A; //计算分配b的值
打印F(%D,B);
返回0;
}
- 什么是b的值?
- 什么是它的计算?
解决方案
有关更多信息一看<一个href=\"http://stackoverflow.com/questions/859433/which-issues-have-you-encountered-due-to-sequence-points-in-c-and-c\">here和<一个href=\"http://stackoverflow.com/questions/3812850/output-of-multiple-post-and-$p$p-increments-in-one-statement\">output-of-multiple-post-and-$p$p-increments-in-one-statement.
int main()
{
int b=0,a=1;//initialize a and b
b=++a + ++a;// calculate assign the value of b
print f("%d",b);
return 0;
}
- what is the value of b?
- and what is the calculation for it?
解决方案
This is Undefined Behaviour.Lack of sequence point.
For more info have a look here and output-of-multiple-post-and-pre-increments-in-one-statement.
这篇关于INT B = 0,A = 1; B = + A + ++中;什么是b的值?什么是它的计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文