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

Problem

Read integers from standard input, separated by spaces or

newlines, until end of input (EOF). Determine and print

how many distinct values appear in the sequence.

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

file. Use while (cin >> x) to detect end of input.

Input:

One or more lines contain integers, separated by

spaces or newlines.

- the total number of values read is between 0 and 1000

- values are integers between -1.000.000 and 1.000.000

Output:

The program prints to standard output a single non-negative integer: how many

distinct values were read. If the input is empty, the program prints

0.

Example:

Input:

1 2 3 2 1 4 5 3

Output:

5

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