#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;
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;
}
因为如果你用%编译器会把它和它后面的字母识别成格式说明用%%来避免这个问题。