作者matrixjimmy (Jimmy)
看板NTUBW
标题[转录][C++] 上机考 (2)
时间Sun Dec 17 14:48:10 2006
※ [本文转录自 NTUBIME97-HW 看板]
作者: ychia (12/13~17 生机周!!) 看板: NTUBIME97-HW
标题: [C++] 上机考 (2)
时间: Wed Dec 8 00:21:06 2004
#include <iostream>
#include <cmath>
using std::cout;
int main()
{
int n = 50; // calculate to n
double i = 1;
double pi = 0;
for ( i = 1; i <= n; i++ )
pi = pi + 1.0 / ( i * i );
pi = sqrt( pi * 6);
cout << "π = " << pi <<"\n";
return 0;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.22.100
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.62.101.203