我想問一d Programming o既野 點打平均數個double?

2006-11-15 7:50 pm
我想問一d Programming o既野

點打平均數個double?

(p.s.唔知人地人幾多個數字)

回答 (2)

2006-11-15 8:23 pm
✔ 最佳答案
不太明白你的問題,亦不太清楚你所需要的東西,答錯不要見怪^^

其實你要用咩language寫,在那裡執行(電腦??計數機??)

用pascal的方式寫個program讓你參考,你可嘗試把它轉換你所用的語言.

program doubleOfMean;

 var sumUp, mean, doubleMean, tempNum : real;
 tempNumString, errorPosition : string;
 icounter : integer;

begin

  icounter := 0;

  repeat
    mean := 0.0;
    doubleMean := 0.0;
    sumUp := 0.0;

    write('Please input number, input 'exit' to calculate DOUBLE of MEAN. ');
    readln(tempNumString);

    if tempNumString <> 'exit' then begin

      val(tempNumString, tempNum, errorPosition); {Change the string to number}
      sumUp := sumUp + tempNum;
      icounter := icounter + 1;

    end;
  until (tempNumString = 'exit'); {exit the repeat-until loop if the user input 'exit'}

  mean := sumUp / icounter; {Calculate the mean}
  doubleMean := 2.0 * mean;

  writeln('Double Mean is : ', doubleMean); {Display the result}

end.
2006-11-15 8:04 pm
你係問咩Programming???
Excel的話便是
(如數值於A1至A5)
=AVERAGE(A1:A5)*2


收錄日期: 2021-04-25 00:03:02
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061115000051KK00952

檢視 Wayback Machine 備份