Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include<iostream>
  2. #include <fstream>
  3. #include<string>
  4. #include<vector>
  5. using namespace std;
  6.  
  7. void main()
  8. {
  9. ifstream json("123456.txt");
  10. string text = "";
  11. char c = json.get();
  12.  
  13. while (json.good())
  14. {
  15. char c= json.get();
  16. text += c;
  17.  
  18. }
  19.  
  20.  
  21.  
  22. string x="x";
  23. string y = "y";
  24. string z = "z";
  25.  
  26. vector<size_t> positionsX;
  27. vector<size_t> positionsY;
  28. vector<size_t> positionsZ;
  29.  
  30. size_t posX = text.find(x, 0);
  31.  
  32. while (posX != string::npos)
  33. {
  34. positionsX.push_back(posX);
  35. posX = text.find(x, posX + x.size());
  36. }
  37. int brojac = 0;
  38. cout << " --- " << positionsX.size() << " " << endl;
  39. while (brojac!=positionsX.size())
  40. {
  41. text.erase(positionsX[brojac] + 10, 8);
  42. brojac++;
  43.  
  44. }
  45.  
  46. size_t posY = text.find(y, 0);
  47.  
  48. while (posY != string::npos)
  49. {
  50. positionsY.push_back(posY);
  51. posY = text.find(y, posY + y.size());
  52. }
  53. int brojac2 = 0;
  54. cout << " --- " << positionsY.size() << " " << endl;
  55. while (brojac2 != positionsY.size())
  56. {
  57. text.erase(positionsY[brojac2] + 10, 8);
  58. brojac2++;
  59.  
  60. }
  61. cout << text;
  62. /*size_t posZ = text.find(z, 0);
  63.  
  64. while (posZ != string::npos)
  65. {
  66. positionsZ.push_back(posZ);
  67. posZ = text.find(z, posZ + z.size());
  68. }
  69. int brojac3 = 0;
  70. cout << " --- " << positionsZ.size() << " " << endl;
  71. while (brojac3 != positionsZ.size())
  72. {
  73. text.erase(positionsZ[brojac3] + 10, 8);
  74. brojac3++;
  75. }*/
  76.  
  77. json.close();
  78.  
  79. std::ofstream upisati;
  80.  
  81. upisati.open("123456C.txt", std::ios_base::app);
  82. upisati << text;
  83. cout << text;
  84. system("PAUSE>0");
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement