#include
main()
{int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("%.*f",c,1.0*a/b);
getch();}
不是最好的方法 a应当用float型否则值域不够大
另外c>20时无法正确输出
#include
int main()
{
int a = 1, b = 6, c = 4;
char str[100];
sprintf(str, "%s%d%s", "%.",c,"lf");//题目要求c很大,需要自己模拟除法
printf(str, a * 1.0 / b);
return 0;
}
#include
int main(void)
{
int a = 1, b = 6, c = 4;
printf("%.*lf\n", c, (double)a / (double)b);
return 0;
}
试了一下应该可以。。