Computer Programming (I)

Programming Assignment 2

This programming assignment consists of 10
problems. Download this cpp file and add your code.
The problems are:

1.
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. Take proper action when no integers are
read in.

3.
Same condition as before, print out the average of
these integers.

4.
Same condition as before, print out the number of
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 integers are read 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
integers that is equal to the largest value in Problem 7.

10.
期中考有這樣一題：

寫一for loop印出1, 3, 5, …, 199。

正確答案為

**for (i=1; i<=199; i+=2)
cout << i
<< endl;**

這種簡單規則的題目和答案可以用出題程式自動產生，只要輸入幾個參數後出題程式就會輸出題目以及答案。請寫一程式，讀入四個數(如上例的1, 3, 5, 199)，自動產生題目及答案。

!!!此題很難，尤其是當輸入值不合理時，如1, 3, 5, -100。可假設輸入參數合理，但你必須正確處理上行或下行兩種可能。