Calculate the value of π from the infinite series
$\pi=4-\frac{4}{3}+\frac{4}{5}-\frac{4}{7}+\frac{4}{9}-\frac{4}{11}+\cdots$
Print a table that shows the approximate value of π after each of the first 1000 terms of this series.
Calculate the value of π from the infinite series
$\pi=4-\frac{4}{3}+\frac{4}{5}-\frac{4}{7}+\frac{4}{9}-\frac{4}{11}+\cdots$
Print a table that shows the approximate value of π after each of the first 1000 terms of this series.
No need for input. You are required to print a table.
// set floating-point number format
cout << fixed << setprecision( 8 );
输入
输出
1 4.00000000 2 2.66666667 3 3.46666667 4 2.89523810 5 3.33968254 6 2.97604618 7 3.28373848 8 3.01707182 9 3.25236593 10 3.04183962 (NOTE: Only 10 items are shown here, you need to output 1000 items)