fork(1) download
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. typedef struct {
  7. double x1,y1,x2,y2; } Point;
  8.  
  9. void readvals(const char*s,std::vector<Point>&v)
  10. {
  11. int n = 0;
  12. Point p;
  13. while (2 == sscanf(s += n, "%*[^']'%lf','%lf'%n", &p.x1, &p.y1, &n)
  14. &&
  15. 2 == sscanf(s += n, "%*[^']'%lf','%lf'%n", &p.x2, &p.y2, &n)
  16. )
  17. v.push_back(p);
  18. }
  19.  
  20. int main()
  21. {
  22. std::vector<Point> v;
  23. std::string s="[['1.81592098644987','52.5487429714954'],['-1.81592290792183','52.5487234624632'],['-99.88','77.66'],['-0.55','44.33']]";
  24. readvals(s.c_str(),v);
  25. for(auto const &p: v) std::cout << p.x1 << p.y1 << p.x2 << p.y2 << '\n';
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1.8159252.5487-1.8159252.5487
-99.8877.66-0.5544.33