C/C++中的i++ i-- ++i --i

// CKeyWord.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) 
{
    //i++是先使用i的值进行调用再计算++,i--同理
    //++i是先将i的值加1,再调用,--i同理
    int i=1;
    cout<<i<<endl;
    cout<<i<<" i-- "<<i--<<endl;    //0 1
    cout<<i<<" i++ "<<i++<<endl;    //1 0
    cout<<i<<" --i "<<--i<<endl;    //0 0
    cout<<i<<" ++i "<<++i<<endl;    //1 1

        system("pause");
    return 0;
    
}


运处结果:

1

0 1

1 0

0 0

1 1 

posted @ 2014-11-05 14:58  明月忧忧  阅读(367)  评论(0编辑  收藏  举报