Re: [Q]計程考古題答案

看板NTUBIME96-HW作者 (OK)時間22年前 (2003/11/20 11:13), 編輯推噓3(300)
留言3則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《pipibjc ( )》之銘言: : : 【第五題】 : : // 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? 一次就好了...吧?! 除兩次沒錯吧?!因為是n平方分之一啊.... : : } : : cout << "S = " << s << endl; // Output the result : : } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.170.121

推 140.112.30.91 11/20, , 1F
題目不是1/n嗎?@@a
推 140.112.30.91 11/20, 1F

推140.112.170.121 11/20, , 2F
是n平方吧.....網頁上平方那個2有點模糊
推140.112.170.121 11/20, 2F

推140.112.170.121 11/20, , 3F
板上po的是一次,網頁上的是平方......
推140.112.170.121 11/20, 3F
文章代碼(AID): #_l34zmb (NTUBIME96-HW)
文章代碼(AID): #_l34zmb (NTUBIME96-HW)