自己制御浮動小数点数後桁数の出力


a,b,cの3つの正の整数を入力し、a/bの小数形を出力し、小数点後のcビットまで正確にし、終了フラグはa=b=c=0である.
サンプル入力:
1 6 4
0 0 0
サンプル出力:
Case 1: 0.1667
コードは以下の通りです:(親測定有効)
#define LOCAL
#include 
#include 

int main()
{
	#ifdef LOCAL
	freopen("data.in","r",stdin);
	freopen ("data.out","w",stdout);
	#endif
	
	int kase = 0, a, b, c;
	while(scanf("%d %d %d", &a, &b, &c) == 3 && (a != 0) && (b != 0) && (c != 0))
	{
		double d = (double)a/b;
		int tempint = (int)d;
		int tempflt = (int)(pow(10,c + 1) * (d - tempint));
		if(tempflt % 10 > 5)
		{
			tempflt = tempflt / 10 + 1;
		}
		else
		{
			tempflt = tempflt / 10;
		}
		
		printf("Case %d:%d.%d
",++kase, tempint, tempflt); } return 0; }