int main (void) {
int a,b;
printf("请输入a、b,以空格间隔:");
scanf ("%d %d",&a,&b);
printf ("%d+%d=%d\n",a,b,a+b);
printf ("%d-%d=%d\n",a,b,a-b);
printf ("%d*%d=%d\n",a,b,a*b);
printf ("%d/%d=%d\n",a,b,a/b);
return 0;
}
运行结果
#include
int main()
{
int a,b,c,d,e,f;
printf("请输入一个整数:");
scanf("%d",&a);
printf("请再输入一个整数:");
scanf("%d",&b);
c = a+b;
d = a-b;
e = a*b;
f = a/b;
printf("两数和是%d,差是%d,积是%d,商是%d。", c, d, e, f);
return 0;
}
#include
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d + %d = %d\n",a,b,a+b);
printf("%d - %d = %d\n",a,b,a-b);
printf("%d * %d = %d\n",a,b,a*b);
printf("%d / %d = %d\n",a,b,a/b);
return 0;
}
看了这几个回答。感觉都没有实现题目中“保证输入和输出全部在整型范围内”的要求。(我是查怎么实现的。但是查了半天。目前看到的,几乎都是像这几个回答这么写的
#include
int main()
{
int a=0;
int b=0;
scanf("%d,%d,&a,&b")
printf("%d + %d = %d",a,b,a+b);
return 0;
}