作者pipibjc ( )
看板NTUBIME96-HW
标题Re: 计程考古题答案
时间Thu Nov 20 00:10:07 2003
: 【第五题】
: // Problem 5
: #include "stdafx.h"
: #include <iostream>
: using std::cin;
: using std::cout;
: using std::endl;
: void main(void)
: {
: float s = 0.0;
: int n;
: cout << "Please give the number of terms in the S series\n";
: cin >> n; // Get the number of terms
: for( int i=1; i<=n; i++) // Calculate the S series
: {
: s = s + 1.0/i/i;
^^^ 要除两次i? 一次就好了...吧?!
: }
: cout << "S = " << s << endl; // Output the result
: }
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.229.80.251
1F:→ sima:对阿 除一次 老师的答案错了 推 140.112.25.184 11/20
2F:→ pipibjc:多谢XD! 推 61.229.80.251 11/20