Storing into a vector without pressing ENTER at each insertion

1

It is necessary to store in a vector a sequence of numbers, but pressing the ENTER only at the end of the line.

For example:

ENTRADA: 10 20 30 15 50 <ENTER>
Vetor[] = {10, 20, 30, 15, 50}
    
asked by anonymous 03.04.2018 / 21:34

1 answer

0

If you are using c ++ you can use a vector which is simple so you can add numbers as you read them.

As for reading itself can do in many ways. One of the most straightforward is with stringstream . In this scenario the reading can be all done from cin at once only with% href="

03.04.2018 / 23:05