#include <stdio.h>
int main()
{
int x,y;
x = 10;
y = -3;
printf("x+y=%d\n",x+(y));
printf("x-y=%d\n",x-(y));
printf("x*y=%d\n",x*(y));
printf("x/y=%d\n",x/(y));
printf("x%%y=%d\n",x%(y));
return 0;
}
可以把y的括号去掉试一试
#include <stdio.h>
int main()
{
int x,y;
x = 10;
y = -3;
printf("x+y=%d\n",x+y);
printf("x-y=%d\n",x-y );
printf("x*y=%d\n",x*y );
printf("x/y=%d\n",x/y );
printf("x%%y=%d\n",x%y );
return 0;
}
正确的方法