#C12686. Process Floats
Process Floats
Process Floats
You are given a list of strings, each representing a floating-point number. Your task is to calculate the sum of these numbers and also produce a list where each number is rounded to one decimal place. Specifically, if the input list is S = [s_1, s_2, \dots, s_n]
, you need to compute:
\( \text{sum} = \sum_{i=1}^{n} x_i \) where \( x_i = \text{float}(s_i) \),
and produce the list \( R = [r_1, r_2, \dots, r_n] \) where \( r_i = round(x_i, 1) \).
If the list is empty, both the sum and the rounded list should be considered as 0 and an empty list respectively.
This is a complete problem and you must implement a solution that reads input from stdin and writes the result to stdout.
inputFormat
The input consists of several lines. The first line contains an integer n, representing the number of strings. The following n lines each contain a string that represents a floating point number.
For example:
3 1.234 5.678 9.1011
outputFormat
The output should consist of two lines. The first line should print the sum of the floating-point numbers. The second line should print the rounded numbers (each rounded to one decimal place) in the same order as the input, separated by a single space. If the list is empty, output 0.0 for the sum and an empty second line.
Note: Ensure that the sum is calculated with full precision and then rounded appropriately if needed.
## sample3
1.234
5.678
9.1011
16.0131
1.2 5.7 9.1
</p>