C语言,计算2个正整数的和,差,积,商并输出.题目保证输入和输出全部在整型范围内

2024-10-27 21:47:00
推荐回答(2个)
回答1:


图中的做法会出现忽略scanf返回值的警告

改成这样就没问题了↓

(修改方法参考https://zhidao.baidu.com/question/1759730286377914268.html的回答)

#include

int main(void)

{

unsigned int A,B;//要求是正整数所以要用unsigned int

if(scanf("%d%d",&A,&B)==2){;

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;

}



亲测正确的请采纳哦😃

回答2:

#include
int main()
{
scanf("%d%d",&a,&b);

printf("%d + %d = %d\n",a+b);

printf("%d - %d = %d\n",a-b);
printf("%d * %d = %d\n",a*b);
printf("%d / %d = %d\n",a/b);
return 0;
}

对不对啊!!!对的话采纳下呗,我想看直播去了……