一邊回顧基礎一邊記錄記錄做個整理,這篇關於for循環的執行順序:
for(表達式1;表達式2;表達式3)
{循環體}
第一步,先對表達式1賦初值;
第二步,判別表達式2是否滿足給定條件,若其值為真,滿足循環條件,則執行循環體內語句,然後執行表達式3,然後進入第二次循環。若判斷表達式2的值為假,就終止for循環,執行循環體外語句。
例一
int main(int argc, char* argv[])
{
for(inti=0;i<5;i++)
cout<<i<<”\t”;
return0;
} /* 何問起 hovertree.com */
輸出為 0 1 2 3 4
例二
int main(int argc, char* argv[])
{
int i=0;
for(i=0;i<5;i++)
cout<<i<<"\t";
cout<<i<<"\t";
return 0;
} /* 何問起 hovertree.com */
輸出為 0 1 2 3 4 5
推薦:
http://www.cnblogs.com/roucheng/p/cpptimu.html