#K56242. Mixed Sum
Mixed Sum
Mixed Sum
Problem Statement: Given a list of tokens provided via STDIN representing integers, floats, or strings, compute the sum of all values that can be interpreted as numbers. For tokens that are numeric strings (e.g. "2" or "3.5"), convert them to numbers and include them in the sum. Non-numeric strings should be ignored.
The sum is defined as \( \text{sum} = \sum_{i=1}^{n} v_i \), where \( v_i \) is the numerical value of the token if it can be converted to a number, and it is skipped otherwise.
Input and Output: Read input from STDIN and write the result to STDOUT.
inputFormat
Input Format:
- The first line contains an integer \(N\), the number of tokens.
- The second line contains \(N\) space-separated tokens, each of which can be an integer, a float, or a string.
outputFormat
Output Format:
- Output a single number: the sum of all tokens that can be converted to a number. The output should be printed as a float.
5
1 2 3.5 apple 4
10.5