| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Adding Imported Indefinite Numbers
I'm just beginning C++ and came across a project I can't seem to figure out and if anyone could help me understand the method it would be incredibly pleasing.
Basically, I have to add an indefinite amount of natural numbers of indefinite length imported from a given file in the format displayed below: 1 2 9 8 5 3 2 1 2 9 8 7 4 3 2 1 1 9 \\ 1 1 2 2 1 3 1 1 4 6 8 8 8 \\ 8 1 2 9 8 5 3 2 1 2 9 8 7 4 3 2 1 1 9 \\ 9 9 9 1 1 2 2 1 3 1 1 4 6 8 8 8 \\ Then, I have to export the found sum to another file in the same format. Any help at all would be welcome at your leisure. |
|
#2
|
|||
|
|||
|
One way to approach this would be to input integers into an array or vector until the input fails (because if it wants an integer it will fail on the string \\). Then sum them, and output into another file. For file I/O, look at the fstream library.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Adding Imported Indefinite Numbers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|