精準計算機

 avatar
user_3763047219
c_cpp
2 years ago
383 B
3
Indexable
Never
#define _CRT_SCURE_NO_WARNINGS
#include <iostream>

int main(){
	int a=0, b=0, N=0;
	int ans=0,resdual[10000] = { 0 };
	scanf("%d %d %d", &a, &b, &N);
	ans = a / b;
	a = a - (a / b) * b;
	for(int i=0;i<N;i++) {
		resdual[i] = (a * 10) / b;
		a = a * 10 - ((a * 10) / b) * b;
	}
	printf("%d.", ans);
	for (int i = 0; i < N; i++) {
		printf("%d", resdual[i]);
	}

}