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