Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <sstream>
- std::vector<int> split(const std::string &s, char delim) {
- std::vector<int> elems;
- std::stringstream ss(s);
- std::string number;
- while(std::getline(ss, number, delim)) {
- elems.push_back(std::stoi(number));
- }
- return elems;
- }
- int main() {
- std::string input;
- double final = 0;
- // const std::string numbers("102:330:3133:76531:451:000:12:44412");
- std::cin >> input;
- for (auto i : split(input, '+')) {
- final = final + i;
- }
- std::cout << "final: " << final << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement