#includestdio.hint main() {int i = 0;printf("%d\n", i++);//先赋值再+1,结果为0int x = 0;printf("%d\n", ++x);//先+1再赋值,结果为1int y = 0;y++;printf("%d\n", y);int z = 0;++z;printf("%d\n", z);//y和最终结果都为1return
#include<stdio.h>
int main() {
int i = 0;
printf("%d\n", i++);
//先赋值再+1,结果为0
int x = 0;
printf("%d\n", ++x);
//先+1再赋值,结果为1
int y = 0;
y++;
printf("%d\n", y);
int z = 0;
++z;
printf("%d\n", z);
//y和最终结果都为1
return 0;
}
例题:
答案为:9 23 8
int main() {
int a, b, c;
a = 5;
c = ++a; //c=6 a=6
b = ++c, c++, ++a, a++; //逗号表达式,b=7,c=8,a=8
b += a++ + c; //b=7+8+8=23,a=9
printf("%d %d %d ", a, b, c);
return 0;
}
其中逗号表达式详情见:常见表达式_wx645804b23d0b2的技术博客_51CTO博客