#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;
}
printf("x%y=%d\n", x%y ); 这里要printf("x%%y=%d\n", x%y ); 不然%y会被认定为格式符号(%d.%s.%c这种).
一个%相当于%d,%s,之类东西,系统会将%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;
}