编程题:15
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double eps = scanner.nextDouble();
double pi = 0;
double term = 1;
int n = 0;
while (term >= eps) {
pi += term;
n++;
term = term * n / (2 * n + 1);
}
pi *= 2;
System.out.printf("%.6f", pi);
}
}
浙公网安备 33010602011771号