#include <math.h>
#define PI acos(-1)
主要是利用利用数学函数中的反三角函数,但是要注意一定引入math包
arccos
(
−
1
)
=
π
\arccos(-1)=\pi
arccos(−1)=π
完整示例:
//#define LOCAL
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
#define PI acos(-1)
int main()
{
printf("%.30lf\n",PI);
return 0;
}
结果:
位数一般够了。