C语言求π的方法

#include <stdio.h>

#include <math.h>

int main()

int r; 

double PI,s; 

scanf("%d",&r); 

PI= atan(1.0)*4; 

s = PI*r*r; 

printf("%.7f",s);  

return 0;

}

这里的atan是反正切函数arctan,正切函数tan(π/4)=1,所以atan(1)=π/4,pi=4.0*atan(1.0)=3.14159......

文章参考自:https://blog.csdn.net/u013866359/article/details/41287399

原文地址:https://www.cnblogs.com/yeshenmeng/p/11457097.html