think:
i++ 會先執行後加1
++i會加1後執行
1. 題目: i++和++i的差別
2. 程式碼:
// i++ and ++i
#include <iostream>
using namespace::std;
int main()
{
int x = 0;
int product = 4;
int quotient = 7;
product *= x++; // part a statement
cout << "Value of product after calculation: " << product
<< endl;
cout << "Value of x after calculation: " << x << endl
<< endl;
x = 0;
quotient /= ++x;
cout << "Value of quotient after calculation: "
<< quotient << endl;
cout << "Value of x after calculation: " << x << endl
<< endl;
system("PAUSE");
return 0;
}
3. 顯示結果:
文章標籤
全站熱搜
