Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <sstream> // std::stringstream
- using namespace std;
- int main() {
- string input;
- string word;
- int sum =0;
- while(getline(cin, input)){
- stringstream stream(input);
- while(stream >> word!=0) {
- int number = atoi(word.c_str());
- sum += number;
- }
- if (input.empty())
- break;
- cout << sum << endl;
- }
- }
Add Comment
Please, Sign In to add comment