今天学习C++发现一个问题
int main()
{
for(int i=0;i<5;i++)
{
cout<<i;
}
cout<<endl;
int s=0;
while(s++<5)
{
cout<<s;
}
return 0;
}
上述代码的输出为
01234
12345
for 循环是 int i=0,判断i是否小于5,如果小于5,则执行循环体,然后i++
while循环是int s=0,判断s是否小于5,如果小于5,则s++,然后再执行循环体