题目描述
Problem Description
Xiao Q has provided you with several lines of strings, which contain some integers interspersed with other characters. You need to output the sum of all integers in each line. If a line contains no numbers, do not output anything. There is always a delimiter character between any two integers (see Sample 3).
Note that the integers in the problem are simple, meaning they do not have extra symbols in front of them. If there is a . in the data, it should be considered as a delimiter.
Input Format
Each line contains a string.
Output Format
For each string that contains integers, output one line with the sum of those integers.
Sample Input and Output
Sample Input #1
su57jdkjth54hjsns-321d 8 ejre
erg(&-^%
weruy4uhnd-
Sample Output #1
-202
4
Sample Input #2
4532984 d -1
Sample Output #2
4532983
Sample Input #3
1-1
1 -1
1--5
1-----------1
-1-1
--1
-2.3
Sample Output #3
2
0
-4
0
0
-1
1
Notes
Sample Explanation
- In the first sample, the first line contains the numbers $57, 54, -321, 8$, with a sum of $-202$; the second and third lines contain no numbers; the fourth line contains only one number $4$, so output $4$.
- In the second sample, there is only one line with two numbers, and their sum is $4532983$.
- In the third sample, for the first line, since there is always a delimiter character between any two integers, the
-is considered a delimiter, resulting in a sum of $2$. For the fifth line, the first number is $-1$, so the second-is considered a delimiter, resulting in a sum of $-1 + 1 = 0$. For the seventh line, the.is considered a delimiter, resulting in a sum of $-2 + 3 = 1$.
Data Range
Note: "Condition A" means the data does not contain characters other than digits, spaces, newlines, and horizontal tabs; "Condition B" means there is exactly one space between any two numbers.
Since the data was generated under Windows, there may be extra $\r$ characters at the end of the lines. Please be aware.
- For $10\%$ of the data, Condition A and B are satisfied, and each line contains exactly $10$ numbers.
- For $40\%$ of the data, Condition A and B are satisfied, and there are no empty lines.
- For $50\%$ of the data, Condition A and B are satisfied.
- For $70\%$ of the data, Condition A is satisfied.
- For $100\%$ of the data, there are no invisible characters other than horizontal tabs, spaces, and newlines, each line does not exceed $1000$ characters, each line contains at most $200$ integers, there are no more than $100$ lines, and each integer is within the range $[-10^7, 10^7]$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分