#include <cstdio>
int main (void)
{
long long a,b;
int c;
while (scanf ("%lld%lld%d",&a,&b,&c) == 3 && !(a == 0 && b == 0 && c == 0))
{
printf ("%lld.",a/b);//先输出整数部分和小数点
a %= b;
for (int i = 1; i < c; i++)
{
printf ("%lld",a*10/b);
a = a*10%b;
}
if (a*10%b*10/b < 5)//对需要输出的最后一位进行是否进位的判断
printf ("%lld",a*10/b);
else
printf ("%lld",a*10/b+1);
}
return 0;
}
ACM分数转小数
猜你喜欢
转载自blog.csdn.net/yestin_L/article/details/81606154
今日推荐
周排行