Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*4. Ñîçäàòü ñïèñîê èç ñëîâ. Ïîäñ÷èòàòü, ñêîëüêî ñëîâ íà÷èíàåòñÿ
- íà äàííóþ áóêâó.
- Ñîçäàòü èç íèõ íîâûé ñïèñîê, óäàëèâ èõ èç èñõîäíîãî ñïèñêà.*/
- #include <fstream>
- #include <string>
- #include <queue>
- using namespace std;
- int main(){
- queue<string> q1;
- queue<string> q2;
- string str, a;
- int cnt = 0;
- ifstream in ("input.txt");
- ofstream out ("output.txt");
- in >> a;
- while (in >> str){
- q1.push(str);
- if (str.find_first_of(a) < string::npos) cnt++; }
- in.close();
- while (!q1.empty()){
- string q = q1.front();
- if (q.find_first_of(a) != string::npos){ q1.pop(); continue;} else q2.push(q);
- q1.pop();
- }
- while (!q2.empty()){
- out << q2.front() << ' ';
- q2.pop();}
- out << '\n' << "Count = " << cnt << endl;
- out.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment