输入正整数a,b,c,输出a/b的小数形式,精确到小数点后c位。a,b<=10^6,c<=100。输入包含多组数据结束标志为a=b=c=0。
#include <stdio.h>
int main()
{
int a,b,c,count=1;
while (1)
{
scanf("%d%d%d",&a,&b,&c);
if(a==0&&b==0&&c==0)
break;
printf("Case %d: %.*f",count++,c,(double)a/(double)b);
}
return 0;
}
//注:使用 * 来精确到小数点后c位的方法来自