#include<stdio.h>
void main()
{
int a,b;
int he,cha,ji,yu;
float shang;
printf(“\n请输入2个数值\n”);
scanf(“%d\n%d”,&a,&b);
he=a+b;
cha=a-b;
ji=a*b;
shang=a/b;
yu=a%b;
printf(“\n和为:%d\n”,he);
printf(“\n差为:%d\n”,cha);
;
printf(“\n积为:%d\n”,ji);
printf(“\n商为:%3.5f\n”,shang);
printf(“\n余为:%d\n”,yu);
}
输入整数可以,如果整数和小数都可输入怎么写呢?
谢谢
>> 本文固定链接: http://www.vcgood.com/archives/1848
全部写成float不就行了吗,,
void main()
{
float a,b;
float he,cha,ji;
int yu;
float shang;
printf(“\n请输入2个数值\n”);
scanf(“%f,%f”,&a,&b);
he=a+b;
cha=a-b;
ji=a*b;
shang=a/b;
yu = int(a)%int(b);
printf(“\n和为:%5.2f\n”,he);
printf(“\n差为:%5.2f\n”,cha);
printf(“\n积为:%5.2f\n”,ji);
printf(“\n商为:%5.2f\n”,shang);
printf(“\n余为:%d\n”,yu);
}
不知道你是不是这个意思