程式碼:
import java.util.Scanner;
public class a248_新手訓練_陣列應用_Math_Round {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String str1;
String[] sp;
int a, b, N;
int sum;
int divisor;
String output;
while(input.hasNext()) {
str1 = input.nextLine();
sp = str1.split(" ");
a = Integer.parseInt(sp[0]);
b = Integer.parseInt(sp[1]);
N = Integer.parseInt(sp[2]);
output = "";
sum = a / b;
output += Integer.toString(sum) + ".";
for(int i = 0; i < N; i++) {
if(a % b == 0) {
output += "0";
continue;
}
divisor = a % b;
a = divisor * 10;
output += Integer.toString(a / b);
}
System.out.println(output);
}
}
}