Z-Scoring an Entire Array at Once
Fenwick College prints a z-score beside every raw mark, so that a mark can be read against the class it came from rather than against an absolute scale. A z-score says how many standard deviations a mark sits above or below its class centre: 0 means exactly on the centre, +1 means one standard deviation above it, a negative figure means below. Two conventions are fixed by the college and printed in the handbook: the centre is the class's arithmetic mean, and the class counts as the whole population rather than a sample of a wider one.
Task: Print the z-score of every mark, keeping the marks in the order they were given.
Input
The first line holds a single integer n, the class size. Each of the next n lines holds one mark, which may carry decimals. The marks are never all identical, so the class always has some spread.
Output
One line holding n z-scores in the input order, separated by single spaces, each with two digits after the decimal point. A mark sitting exactly on the centre prints as 0.00.
Example:
Input:
4
2
4
4
6
Output:
-1.41 0.00 0.00 1.41
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