fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. string x;
  10. string PointsX[10000];
  11. string PointsY[10000];
  12. float X[10000];
  13. float Y[10000];
  14. int length = x.length(), n = 0;
  15. int index1, index2, index3;
  16. string Px, Py;
  17.  
  18. cout << "Enter string" << endl;
  19. getline(cin, x);
  20.  
  21. //ta2tee3 el string:
  22.  
  23. for (int i = 0; i < length; i++)
  24. {
  25. if (x[i] == '(')
  26. {
  27. index1 = i + 1;
  28. }
  29. else if (x[i] == ',')
  30. {
  31. if (x[i - 1] != ')')
  32. {
  33. index2 = i;
  34. }
  35. }
  36. else if (x[i] == ')')
  37. {
  38. index3 = i - 1;
  39. n = n + 1;
  40. PointsX[n] = x.substr(index1, index2 - index1);
  41. PointsY[n] = x.substr(index2 + 1, index3 - index2);
  42. }
  43. }
  44. cout << PointsX[n] << endl << PointsY[n] << endl;
  45. return 0;
  46. }
Success #stdin #stdout 0s 15744KB
stdin
(1,1),(4,1),(4,5),(1,5);(3,4),(6,4),(6,12),(3,12)
stdout
Enter string