Board logo

標題: [ICT] ONE question about Array [打印本頁]

作者: Yanase    時間: 2011-8-10 02:15 PM     標題: ONE question about Array

Question: Design an algorithm with a WHILE-loop for finding the mean of the elements in an array of the numeric type.

ANS:




Shouldnt there be a step 'Input item*' before 'sum = sum + item*' ?

*There should be a 'i' here. There is error it cant show.

Please post here if you know. Thank you!!!!!!


作者: 闈場    時間: 2011-8-12 01:40 PM

吾係好明你問咩,,不過都試下解一解,
我估你係問緊點解"i = i +1;" 吾可以響" sum = sum + i;" 前面,
其實好簡單,
如果你行左i果句先, 咁個sum就會係sum=sum+"2",
因為你個i 加左1;

其實你係問個array定係問緊個loop嫁!?
作者: kelvinchung1014    時間: 2011-8-15 09:36 AM

你可以當佢叫你寫一個procedure(唔係成個program), aim to find the mean of one element. 至於 item 既array 係咩呢,,就可以唔洗理喇. 所以答案冇錯. (如果你話要加 readln(item) 既,,咁 how about n? ,,所以唔洗加 Input item* ).




歡迎光臨 小卒資訊論壇 (http://www.lsforum.net/board/) Powered by Discuz! 6.0.0