#C14922. Average Rainfall Calculation
Average Rainfall Calculation
Average Rainfall Calculation
You are given a list representing the rainfall amounts for several days. Some days may have no rainfall, represented by a value of 0. Your task is to compute the average rainfall for the days where rainfall occurred (i.e. the value is not 0), and print the result rounded to two decimal places. If there are no days with rainfall (or if the list is empty), the output should be 0.00
.
Note: All formulas and calculations involving the average should be computed as follows: \( \text{average} = \frac{\sum_{i=1}^{n} a_i}{n} \), where \(a_i\) are the non-zero rainfall values and \(n\) is the count of those values.
inputFormat
The input is read from standard input (stdin
) and consists of:
- The first line contains an integer n representing the number of days.
- The second line contains n space-separated integers where each integer represents the rainfall amount for a day.
outputFormat
Print a single line to standard output (stdout
) that shows the average rainfall (ignoring days with no rainfall) rounded to two decimal places. If there is no day with rainfall, output 0.00
.
10
23 0 12 0 8 15 27 0 7 0
15.33