Sum of subsequences

Write a program that reads a sequence of subsequences of natural
numbers, and prints the sum of each subsequence.

To solve this exercise, write a procedure

        void read_and_add(int& sum, bool& end);

that reads a subsequence of natural numbers separated by |’+’| ended in
comma or dot, returns the sum of the read integer numbers in the output
parameter |sum|, and indicates if the read subsequence was the last
sequence with the output parameter |end|. This case is detected because
the las subsequence is the only one which end with a dot.

Input

Input consists of a non empty sequence of non empty subsequences of
natural numbers. In each subsequence, the integer numbers are separated
by |’+’|. All the subsequences end in comma, except the last one, that
ends in a dot.

Output

Your program must print the sum of the elements of each subsequence in a
different line.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:19:51.101Z

© Jutge.org, 2006–2026.
https://jutge.org
