Home > Backend Development > PHP Tutorial > while里头的i++ ++i 到底是啥意思,老是搞混

while里头的i++ ++i 到底是啥意思,老是搞混

WBOY
Release: 2016-06-13 12:58:45
Original
1476 people have browsed it

while里面的i++ ++i 到底是啥意思,老是搞混
++i
i++
+i
i+

这四个到底是啥意思,老是搞混淆!
------解决方案--------------------
这个很简单的了,看个例子就弄明白了:

int a = 3;<br />
int b = 0;<br />
int i = 1;<br />
<br />
b = ++i + a;//先把i加1,i等于2,再和a相加,b = 2 + 3 = 5;<br />
b = i++ + a;//i值不变,先和a相加,b = 1 + 3 = 4; 然后i加1,i等于2;
Copy after login


不过在for语句里面做判断,前置和后置都差不多。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template