求租独院教育花都:编写一个c程序,实现两个数的相除功能,分别输出商和余数

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 17:50:01
#include<stdio.h>
void main()
{
int a,b;
float c;
c=a%b;
printf("a=35\nb=6");
scanf("\na/b",&a,&b);
printf("c=%d,d=%f",c);

}
我的程序好像写的不对,谁帮我能改你该阿

#include<studio.h>
main()
{int a,b,c,d;
scanf("%d %d",&a,&b);
c=a/b;
d=a%b;
printf("%d/%d=%d.....%d",a,b,c,d);
}
收到你的信,改过来了,刚才一时大意.

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
int a, b;
div_t x;

printf("Please input 2 number : ");
scanf("%d %d", &a, &b);

x = div(a, b);
printf("%d div %d = %d remainder %d\n", a, b, x.quot, x.rem);

return 0;
}

上面3个能作出来但是肯定不是100分

中间加一个判断把

if (b == 0)
{
printf ("error");
return 0;
}

#include<stdio.h>
main()
{
int a,b,c,d;
scanf("%d %d",&a,&b);
c=a/b;
d=a%b;
printf("%d,%d\n",c,d);

}