fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. auto convertStringVectortoDoubleVector(const std::vector<std::string>& stringVector) -> std::vector<double>
  8. {
  9. std::vector<double> doubleVector(stringVector.size());
  10. std::transform(stringVector.begin(),
  11. stringVector.end(),
  12. doubleVector.begin(),
  13. [](const std::string& val) {
  14. return stod(val);
  15. });
  16. return doubleVector;
  17. }
  18.  
  19. int main() {
  20. std::vector<std::string> data;
  21. string s;
  22.  
  23. while (cin>>s) {
  24. data.push_back(s);
  25. }
  26.  
  27. auto result = convertStringVectortoDoubleVector(data);
  28.  
  29. for (auto x : result) {
  30. cout << x << endl;
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 3280KB
stdin
123 123 423 23421 52423 3423 
stdout
123
123
423
23421
52423
3423