i++:
int a =6; int a = i++;
a is 6, i is 7;
原因是:int a = i ++ 为 int a = i ; i + 1; 属于先赋值,再加1.
++i:
int a =6; int a = ++i;
输出:a is 7, i is 7;
原因是 加减的区别在于这个需要先加一,然后再赋值。
int a =6; int a = i++;
a is 6, i is 7;
原因是:int a = i ++ 为 int a = i ; i + 1; 属于先赋值,再加1.
int a =6; int a = ++i;
输出:a is 7, i is 7;
原因是 加减的区别在于这个需要先加一,然后再赋值。
本文标题:i++和++i的区别
本文链接:https://www.haomeiwen.com/subject/vsjyxhtx.html
网友评论