C语言 和、差、积、商和余数.编写程序,输入两个整数number1和number2,计算并输出它们的和、差、积、商和余数(除法不考虑小数部分)另:要判断number2是否为0,如果number2为0,只输出和、差、积然后我以为下面着样可以,结果错了,#include#include int main(void){int num1,num2,no1,no2,no3,no4,no5; scanf("%d%d",&num1,&num2);no1=(num1+num2);no2=(num1-num2);no3=(num1*num2);no4=(num1\num2); .提示这里出错no5=(num1%num2);if(num2==0){ printf("%d\n",no1);printf("%d\n",no2);printf("%d\n",no3);else{printf("%d\n",no1);printf("%d\n",no2);printf("%d\n",no3);printf("%d\n",no5
问题描述:
C语言 和、差、积、商和余数.
编写程序,输入两个整数number1和number2,计算并输出它们的和、差、积、商和余数(除法不考虑小数部分)
另:要判断number2是否为0,如果number2为0,只输出和、差、积
然后我以为下面着样可以,结果错了,
#include
#include
int main(void)
{
int num1,num2,no1,no2,no3,no4,no5;
scanf("%d%d",&num1,&num2);
no1=(num1+num2);
no2=(num1-num2);
no3=(num1*num2);
no4=(num1\num2); .提示这里出错
no5=(num1%num2);
if(num2==0)
{
printf("%d\n",no1);
printf("%d\n",no2);
printf("%d\n",no3);
else{
printf("%d\n",no1);
printf("%d\n",no2);
printf("%d\n",no3);
printf("%d\n",no5);
printf("%d\n",no4);
}
system("pause");
return 0;
}
答
int s ,c,j,shang,yushu,n1,n2;if(n2==0){s=n1+n2;c=n1-n2;j=n1*n2;printf("%d/t%d/t%d/n",s,c,j);}else{s=n1+n2;c=n1-n2;j=n1*n2;shang=n1/n2;yushu=n1%n2;printf("%d/t%d/t%d/t%d/t%d/n",s,c,j,shang,yushu);}输入...