void main() { int a,b; int y; float x; printf("请输入2个数字:"); scanf("%d%d",&a,&b); x =a/b; y =a%b; printf("商:%0.3f",x); printf("余数:%d",y); } 再问: 请问我运行以后计算10/3怎么输出商是3.000? 再答: void main() { int a,b; int y;
float x; printf("请输入2个数字:"); scanf("%d%d",&a,&b); x =(float)a/b;-------------------------这里需要强制转换一下 y =a%b; printf("商:%0.3f",x); printf("余数:%d",y); }