Mobile coding works. A laptop is faster for long sessions.

Problem

Read from standard input a single line containing integers

separated by commas (single-line CSV format). Determine and

print:

1. the number of numeric values on the line;

2. their sum.

The two numbers are printed on a single line, separated by a

space. If the line contains no numeric values, print

0 0.

Spaces between commas and numbers are ignored. Numbers can be

positive or negative (with + or - prefix).

The data are read from standard input (in the format described), not from a

file. Use cin.getline to read the complete line.

Input:

The program reads a single line of at most 4000 characters,

containing integers separated by commas.

- the line length is between 0 and 4000 characters

- numbers are integers between -1.000.000 and 1.000.000

- at most 1000 values per line

Output:

The program prints to standard output two integers, separated by a

space: the count of values and their sum.

Example:

Input:

1,2,3,4,5

Output:

5 15

Ready to solve this challenge?

Create a free account to write code, submit solutions, and track your progress.

⌨️ Keyboard Shortcuts

Code Editor
Run Code
Ctrl Enter
Submit Code
Ctrl Shift Enter
Format Code
Shift Alt F
Toggle Comment
Ctrl /
Undo
Ctrl Z
Redo
Ctrl Y
Navigation
Global Search
/
Show Shortcuts
?
Close Modal
Esc

🔍 Interactive Debugger

0 / 0

Analyzing your code...

📦 Variables

No variables yet

📚 Call Stack
main() line 1
📤 Output