The Neighbor Smoother
Fenwick Mill's temperature probe is jittery enough that the wall chart is unreadable, so the engineers want it calmed before it is posted. Every reading except the two at the ends is replaced by the average of itself and the reading on either side. The first and last readings have only one neighbour each and are posted exactly as they came in.
Task: Print the smoothed run of readings.
Input
The first line holds an integer n, always at least 3. Each of the next n lines holds one reading.
Output
One line per reading, n lines in all, each with exactly one digit after the decimal point. Every replacement is built from the original readings on both sides — never from values that have already been smoothed.
Example:
Input:
3
0
30
0
Output:
0.0
10.0
0.0
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