fork download
  1. #include <fstream>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. int main()
  6. {
  7. // std::ifstream ifstr("YourFile.txt");
  8. // std::istream & istr = ifstr;
  9.  
  10. std::istream & istr = std::cin;
  11.  
  12. std::vector<std::pair<double, double>> vec;
  13.  
  14. double a, b;
  15. char comma;
  16.  
  17. while ( istr >> a >> comma >> b )
  18. {
  19. if ( comma == ',' )
  20. vec.emplace_back(a, b);
  21. }
  22.  
  23. std::for_each(std::begin(vec), std::end(vec), [](std::pair<double, double> const& x){ std::cout << x.first << " -> " << x.second << std::endl;});
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3432KB
stdin
0, 0.3245
0, 0.5566
0, 0.9598
1, 0.0945
1, 0.8748
1, 0.8789
undef, undef
2, 0.035
2, 0.9545 
stdout
0 -> 0.3245
0 -> 0.5566
0 -> 0.9598
1 -> 0.0945
1 -> 0.8748
1 -> 0.8789