编程题: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);
}
}

posted on 2025-05-12 23:22  Swishy  阅读(6)  评论(0)    收藏  举报