可以幫我看一下幾題c++的意思是在講什麼嗎

2006-11-01 7:58 pm
Computer Programming (I)

Programming Assignment 2

Oct. 24, 2006



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。可假設輸入參數合理,但你必須正確處理上行或下行兩種可能。






順便給一些解題建議+方法
更新1:

因為我是新手,身上只有100點而已,所以要省點用

更新2:

感恩喔

回答 (4)

2006-11-01 11:26 pm
✔ 最佳答案
1.讀入一系列整數,遇到-999就停止。印出一共讀入了多少個數字, 但最後的-999不計算在內。2.輸入的部分與上題相同, 但要印出所有整數的總和。如果沒有讀到任何數字, 要做適當的處理。3.所有的情況與上題相同, 但要印出所有數字的平均值。4.所有的情況與上題相同, 但要印出總共有多少個正整數。5.所有的情況與上題相同, 但要印出所有正整數的總和。6.所有的情況與上題相同, 但要印出所有正整數的平均值。如果沒有讀到任何數字, 要做適當的處理。7.所有的情況與上題相同, 但要印出所讀到的最大整數。8.所有的情況與上題相同, 但要印出所讀到的最小整數。9.所有的情況與上題相同, 但要印出與第七題中最大的數字相同的數字一共有幾個。10.(略)這還需要什麼解題建議? 如果你有學C++的輸入, 輸出, 和數字運算, 就照著寫就是了啊。還要建議什麼? 頂多就是要用迴圈去讀啊。
參考: 又學英文又寫程式的人
2014-08-06 7:37 pm
到下面的網址看看吧

▶▶http://*****
2014-07-20 9:33 pm
到下面的網址看看吧

▶▶http://*****
2006-11-01 8:07 pm
只有五點好少喔...


收錄日期: 2021-04-20 21:12:35
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061101000011KK03814

檢視 Wayback Machine 備份