#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;
}
应该是括号里的%被默认为符号了,再加上一个试试
#include <stdio.h>int main(){ int x,y; x = 10; y = -3; int re1,re2,re3,re4,re5; re1=x+y; re2=x-y; re3=x*y; re4=x/y; re5=x%y; printf("x+y=%d\n",re1); printf("x-y=%d\n",re2); printf("x*y=%d\n",re3); printf("x/y=%d\n",re4); printf("x%%y=%d\n",re5); return 0; }