Fw: [徵求] 請幫我看我程式習題理解得對不對

看板Programming作者 (紫藤)時間10年前 (2015/03/11 18:35), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串1/2 (看更多)
※ [本文轉錄自 Wanted 看板 #1L019pP7 ] 作者: Nessa1103 (紫藤) 看板: Wanted 標題: [徵求] 請幫我看我程式習題理解得對不對 時間: Wed Mar 11 18:01:20 2015 有個程式語言的習題要求如下: Description We want to calculate a sum of squares of some integers, excepting negatives The first line of the input will be an integer N (1 <= N <= 100) Each of the following N test cases consists of one line containing an integer X (0 < X <= 100), followed by X integers (Yn, -100 <= Yn <= 100) space-separated on the next line For each test case, calculate the sum of squares of the integers excepting negatives, and print the calculated sum to the output. No blank line between test cases (Take input from standard input, and output to standard output) 他的意思是要我把他給的輸入範例除了負的以外通通平方加起來嗎? 因為他「輸入」的範例給了五行,可是輸出的部分只有兩行。 因為這部分卡住,所以不知道該怎麼寫。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.69.208 ※ 文章網址: https://www.ptt.cc/bbs/Wanted/M.1426068083.A.647.html ※ 發信站: 批踢踢實業坊(ptt.cc) ※ 轉錄者: Nessa1103 (123.193.69.208), 03/11/2015 18:35:27

03/11 19:08, , 1F
照我的理解,輸出兩行的話,輸入應該
03/11 19:08, 1F

03/11 19:09, , 2F
三行; 而且第一行是「2」
03/11 19:09, 2F

03/11 20:29, , 3F
嗯,我說錯了,下一篇應該是正解
03/11 20:29, 3F
文章代碼(AID): #1L01fmL5 (Programming)
文章代碼(AID): #1L01fmL5 (Programming)