编程知识 cdmana.com

I hope you can answer it. I've been struggling for a long time

bosses , There is a tangle in this problem , Namely y The final value , Why 10, The upper one y++ after y The value of plus or not 1, Ask the boss for an answer

img




Refer to the answer 1:
int x=10,y=9;int a,b,c;//  Calculate first  --x, have to  x=9,x==y  establish ,y++, have to  y=10//  because  x==y  establish , So run  --x, have to x=8, therefore  a=8a=(--x==y++)?--x:++y;// b=x  have to  b=8,x Self addition  x=9b=x++;// c=10c=y;



Refer to the answer 2:



Refer to the answer 3:

When participating in the comparison y Is in accordance with the 9 Calculated , At the end of the statement y From to 10, So in the end 8,8,10
Helpful, hope to adopt ~




Refer to the answer 4:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/11/20211119174245959h.html

Scroll to Top