c语言编程:PI 2 = 1 + 1 3 + 1 3 2 5 + 1 3 2 5 3 7+
#include<stdio.h> int main() { double pi=1.0;//定义初始值为1.0 int i,j,k; for(i=1,j=3,k=2;i<=100;i++,j+=2,k+=2)//循环100次 { pi+=1.0*j/k;//累加每一项 } printf("PI/2=%lf\n",pi);//输出结果 return 0; }
原文地址: https://www.cveoy.top/t/topic/bVQo 著作权归作者所有。请勿转载和采集!