Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <sstream>
  4.  
  5. std::vector<int> split(const std::string &s, char delim) {
  6. std::vector<int> elems;
  7. std::stringstream ss(s);
  8. std::string number;
  9. while(std::getline(ss, number, delim)) {
  10. elems.push_back(std::stoi(number));
  11. }
  12. return elems;
  13. }
  14.  
  15. int main() {
  16. std::string input;
  17. double final = 0;
  18. // const std::string numbers("102:330:3133:76531:451:000:12:44412");
  19. std::cin >> input;
  20. for (auto i : split(input, '+')) {
  21. final = final + i;
  22. }
  23.  
  24. std::cout << "final: " << final << std::endl;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement