#includestdiohint main int x=1y=0; !xy++; printfx=d y=dnxy; !y&&++x; printfx=d y = dnxy; return 0;
The output of the code will be:
x=1 y=0 x=2 y=0
Explanation:
- In the first line, the expression
!x||y++is evaluated.xis 1, so!xis false (0). Since the OR operator (||) short-circuits, they++part is not executed. So,yremains 0. Therefore, the first print statement outputsx=1 y=0. - In the second line, the expression
!y&&++xis evaluated.yis 0, so!yis true (1). But, since the AND operator (&&) short-circuits, the++xpart is not executed. So,xremains 1. Therefore, the second print statement outputsx=1 y=0
原文地址: https://www.cveoy.top/t/topic/ilHL 著作权归作者所有。请勿转载和采集!