Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <fstream>
- #include<string>
- #include<vector>
- using namespace std;
- void main()
- {
- ifstream json("123456.txt");
- string text = "";
- char c = json.get();
- while (json.good())
- {
- char c= json.get();
- text += c;
- }
- string x="x";
- string y = "y";
- string z = "z";
- vector<size_t> positionsX;
- vector<size_t> positionsY;
- vector<size_t> positionsZ;
- size_t posX = text.find(x, 0);
- while (posX != string::npos)
- {
- positionsX.push_back(posX);
- posX = text.find(x, posX + x.size());
- }
- int brojac = 0;
- cout << " --- " << positionsX.size() << " " << endl;
- while (brojac!=positionsX.size())
- {
- text.erase(positionsX[brojac] + 10, 8);
- brojac++;
- }
- size_t posY = text.find(y, 0);
- while (posY != string::npos)
- {
- positionsY.push_back(posY);
- posY = text.find(y, posY + y.size());
- }
- int brojac2 = 0;
- cout << " --- " << positionsY.size() << " " << endl;
- while (brojac2 != positionsY.size())
- {
- text.erase(positionsY[brojac2] + 10, 8);
- brojac2++;
- }
- cout << text;
- /*size_t posZ = text.find(z, 0);
- while (posZ != string::npos)
- {
- positionsZ.push_back(posZ);
- posZ = text.find(z, posZ + z.size());
- }
- int brojac3 = 0;
- cout << " --- " << positionsZ.size() << " " << endl;
- while (brojac3 != positionsZ.size())
- {
- text.erase(positionsZ[brojac3] + 10, 8);
- brojac3++;
- }*/
- json.close();
- std::ofstream upisati;
- upisati.open("123456C.txt", std::ios_base::app);
- upisati << text;
- cout << text;
- system("PAUSE>0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement