其实就是两个重点
1:前缀会在表达式运算前获得新值、后缀在表达式运算后获得新值
2:表达式和变量的值是两个概念,要注意分离
#include <iostream>
using namespace std;
int main()
{
int a = 0;
int b = 0;
int i = a++,j = ++b;
cout << i <<" "<< a <<endl;
cout << j <<" "<< b <<endl;
system("pause");
return 0;
}
//0 1
//1 1
#include <iostream>
using namespace std;
int main()
{
int a = 0;
int b = 0;
int i,j ;
printf("%d,%d\n",a,i = a++);
printf("%d,%d\n",b,j = ++b);
system("pause");
return 0;
}
//1 0
//1 1
#include <iostream>
using namespace std;
int main(void)
{
for (int i = 0; i < 10; ++i)
cout << i;
cout << endl;
for (int i = 0; i < 10; i++)
cout << i;
cout<<endl;
system("pause");
return 0;
}
//0123456789
//0123456789