Sum and Average with Sentinel Value


Submit solution

Points: 45 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type

題目說明

請撰寫一個程式,讓使用者輸入一連串的正整數,直到輸入 0 為止。程式應該計算這些數字的總和和平均值,並輸出結果。

輸入

使用者輸入一行包含多個以 空格 分隔的正整數,最後輸入 0 代表結束(0 不計入計算)。

輸出

輸出總和與平均值,平均值請四捨五入至小數點後兩位。

範例輸入 #1

10 20 30 40 0

範例輸出 #1

Sum: 100, Average: 25.00

範例輸入 #2

7 14 21 28 35 42 0

範例輸出 #2

Sum: 147, Average: 24.50

Comments

There are no comments at the moment.