题目如下:
《算法竞赛入门经典》------习题2-5 分数化小数(decimal)_Simone Zeng的博客-CSDN博客
代码如下:
cpp
#include <cstdio>
int a, b, c, k;
int main(){
k = 0;
while(scanf("%d %d %d", &a, &b, &c) == 3 && b){
printf("Case %d: %d.", ++k, a / b);
for(int i = 0; i < c - 1; ++i){
a = a % b * 10;
printf("%d", a / b);
}
a = a % b * 10;
printf("%d\n", (int) (a * 1.0 / b + 0.5));
}
return 0;
}