SHARE
TWEET

Untitled

a guest Sep 18th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top