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.  顯示結果:

 

 

文章標籤
全站熱搜
創作者介紹
創作者 布拉怡 的頭像
布拉怡

nini的部落格

布拉怡 發表在 痞客邦 留言(0) 人氣(56)