- #include<stdio.h>
- int main(){
- int a=1;
- a+=2;//a=a+2
- printf("a的值是%d\n",a);
- a-=1;//a=a-1
- printf("a的值是%d\n",a);
- a++;//a=a+1
- printf("a的值是%d\n",a);
- a--;//a=a-1
- printf("a的值是%d\n",a);
- ++a;//a=a+1
- printf("a的值是%d\n",a);
- --a;//a=a-1
- printf("a的值是%d\n",a);
- printf("a的值是%d\n",a);
- //常量是不能自增自减的
- int c=2;
- int b=c++;//先将c的值赋值给b,然后再把c+1
- printf("b的值是%d,c的值是%d\n",b,c);
- c=2;
- b=++c;//先运算完再赋值给b
- printf("b的值是%d,c的值是%d\n",b,c);
- return 0;
-
复制代码 |
|