Lectures on C++ STL

Ed's avatarLearntofish's Blog

Check out these Channel 9 lectures by Stephan T. Lavavej on the Standard Template Library (STL) in C++.

From the website’s description:

Learn all about the Standard Template Library (STL)  from the great Stephan T. Lavavej (STL), Microsoft’s keeper of the STL cloth (this means he manages the partnership with the owners of STL and Microsoft, including, of course, bug fixes and enhancements to the STL that ships as part of Visual C++).

View original post

Read input of unknown length

Problem:
Suppose you are given the following input:

5 22 9 813 13
77 98 93 51
5 3 1 5 7 1 3
9 1

Your task is to print out the sum of the numbers in each line, e.g. the sum for the first line is

5 + 22 + 9 + 813 + 13 = 862

So the output should be:

862
319
25
10

The problem here is that you don’t know how many lines you are given and how many numbers there are in each line. How can you solve this problem in Python and C++?

Continue reading