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