学渣小白 的学生作业:
#include
// 求出下列数据的答案。(上一个表达式x,y的值会影响下面x和y的值)
int main()
{
int x = 10 ,y =20;
printf(“int x = 10 ,y =20;” “\n”);
int z = 0;
printf(“int z = 0;” “\n”);
printf("\n*************delimiter**************\n");
z = (++x) + (y++);
printf("z = (++x) + (y++);" "\n");
//X is first increased by 1, then assigned to 11, and y is first assigned to 20 before adding 1, so z=11+20=31; x=11; y=21;
printf("//X is first increased by 1, then assigned to 11, and y is first assigned to 20 before adding 1, so z=11+20=31;x=11;y=21;" "\n");
printf("z = %d\n",z);
printf("x=%d\n",x);
printf("y=%d\n",y);
printf("\n*************delimiter**************\n");
z = (--x) + (y++);
printf("z = (--x) + (y++);" "\n");
// x先减1,再赋值为10,y先赋值为21,再减1,所以z=10+21=31;x=10;y=22;
printf("//X is first subtracted by 1 and then assigned a value of 10, y is first assigned a value of 21 and then subtracted by 1, so z=10+21=31; x=10; y=22;" "\n");
printf("z = %d\n",z);
printf("x=%d\n",x);
printf("y=%d\n",y);
printf("\n*************delimiter**************\n");
z= (++x) + (--y);
printf("z= (++x) + (--y);" "\n");
//x先增加1,再赋值为11,y先减1,再赋值为21,所以z=11+21=32;x=11;y=21;
printf("//X is first increased by 1 and then assigned a value of 11, y is first decreased by 1 and then assigned a value of 21, so z=11+21=32; x=11; y=21;" "\n");
printf("z = %d\n",z);
printf("x=%d\n",x);
printf("y=%d\n",y);
printf("\n*************delimiter**************\n");
printf("x = %d y = %d\n",x,y);
return 0;
}
linux@linux:~/test01$ gcc 1i4practicer.c
linux@linux:~/test01$ ./a.out
int x = 10 ,y =20;
int z = 0;
delimiter*
z = (++x) + (y++);
//X is first increased by 1, then assigned to 11, and y is first assigned to 20 before adding 1, so z=11+20=31;x=11;y=21;
z = 31
x=11
y=21
delimiter*
z = (–x) + (y++);
//X is first subtracted by 1 and then assigned a value of 10, y is first assigned a value of 21 and then subtracted by 1, so z=10+21=31; x=10; y=22;
z = 31
x=10
y=22
delimiter*
z= (++x) + (–y);
//X is first increased by 1 and then assigned a value of 11, y is first decreased by 1 and then assigned a value of 21, so z=11+21=32; x=11; y=21;
z = 32
x=11
y=21
delimiter*
x = 11 y = 21
linux@linux:~/test01$