計程Practice Problems

10/18/2007

下列各題每題寫程式。

 

1.         Repeatedly read in integers until -999 is typed in. Print out the number of integers typed in. The last number, -999, does not count. (個數)

2.         Same condition as the previous problem, but print out the sum of these integers instead. (總和)

3.         Same condition as before, print out the average of these integers. Take proper action when no integer is read in. (平均數)

4.         Same condition as before, print out the number of those integers that are positive. (正數個數)

5.         Same condition as before, print out the sum of those integers that are positive. (正數總和)

6.         Same condition as before, print out the average of those integers that are positive. Take proper action when no positive integer is typed in. (正數平均數)

7.         Same condition as before, print out the value of the largest integer typed in. (最大數)

8.         Same condition as before, print out the value of the smallest integer typed in. (最小數)

9.         Same condition as before, print out the number of times the integer 11 appears in the input. (11出現次數)

10.     Same condition as before, print out the number of times the largest value found in Problem 7 appears in the input. (最大數出現次數) (Do not use an array because it is not yet covered.)