Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <list>
- #include <string>
- using namespace std;
- char check;
- bool func(string s)
- {
- return (s[0]==check) ? true : false;
- }
- int main()
- {
- list<string> mainlist;
- ifstream inp("input.txt");
- string input;
- while (inp >> input)
- mainlist.push_back(input);
- list<string> :: iterator it;
- it = mainlist.begin();
- mainlist.sort();
- while (it!=mainlist.end())
- {
- cout << *it << " ";
- it++;
- }
- cin >> check;
- cout << endl;
- list<string> :: iterator seeker=mainlist.begin();
- while (seeker!=mainlist.end())
- {
- seeker = find_if(seeker, mainlist.end(), func());
- if (func(*seeker)) cout << *seeker << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement