fork 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','2'],['3','4'],['5','6'],['7','8'],['9','10'],['10','11'],['12','13'],['14','15']]";
  24. readvals(s.c_str(),v);
  25. for(int i=0;i<v.size()-1;++i)
  26. std::cout << v[i].x1 << v[i].y1 << v[i].x2 << v[i].y2 << " "
  27. << v[i+1].x1 << v[i+1].y1 << v[i+1].x2 << v[i+1].y2 << '\n';
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1234 5678
5678 9101011
9101011 12131415