我正在学习编程,我是从 C 语言开始的。我在读 Let us C 书。我正在经历那本书中的这个程序。
main( )
{
int a[5] = { 5, 1, 15, 20, 25 } ;
int i, j, k = 1, m ;
i = ++a[1] ;
j = a[1]++ ;
m = a[i++] ;
printf ( "\n%d %d %d", i, j, m ) ;
}
我的理解是,它会打印i as 2
,j as 1
并且m as 15
但不知何故,它打印为 i as 3
,j as 2
和m as 15
? 为什么会这样?
以下是我的理解——
b = x++;
In this example suppose the value of variable ‘x’ is 5 then value of variable ‘b’ will be 5 because old value of ‘x’ is used.
b = ++y;
In this example suppose the value of variable ‘y’ is 5 then value of variable ‘b’ will be 6 because the value of ‘y’ gets modified before using it in a expression.
我的理解有什么问题吗?