tinhpi.c
来自「Many C samples. It is a good sample for 」· C语言 代码 · 共 23 行
C
23 行
/* Bai tap 1_29 - Tinh so PI voi sai so 0.0001 */
#include <stdio.h>
#include <math.h>
void main()
{
double PI = 1.0, n = 3.0;
int i = 0;
while (1.0/n > 0.0001)
{
if (i%2 == 0)
PI -= 1.0/n;
else
PI += 1.0/n;
n += 2;
i++;
}
PI *= 4.0;
printf("\nSo PI tinh toan duoc la : %lf", PI);
printf("\nSo M_PI trong C = %lf", M_PI);
getch();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?