⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tinhpi.c

📁 Many C samples. It is a good sample for students to learn C language.
💻 C
字号:
/* 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -