The Running Average
Halcyon Cycles keeps a live figure on the warehouse screen: the average weight of every parcel handled so far today. It refreshes the instant each parcel is weighed, so the screen produces one figure per parcel rather than a single figure at the end of the shift. After the very first parcel there is nothing else to average, so the screen simply shows that parcel's own weight.
Task: After each parcel, print the average weight of every parcel weighed so far.
Input
The first line holds one integer n, how many parcel weights follow. Each of the next n lines holds one weight as a plain number, in the order the parcels were weighed.
Output
n lines, one per parcel, in the same order. Each line holds the average of all weights up to and including that parcel, with exactly two digits after the decimal point.
Example:
Input:
3
10
20
60
Output:
10.00
15.00
30.00
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in