Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <list>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. char check;
  9.  
  10. bool func(string s)
  11. {
  12. return (s[0]==check) ? true : false;
  13. }
  14.  
  15. int main()
  16. {
  17. list<string> mainlist;
  18. ifstream inp("input.txt");
  19. string input;
  20. while (inp >> input)
  21. mainlist.push_back(input);
  22. list<string> :: iterator it;
  23. it = mainlist.begin();
  24. mainlist.sort();
  25. while (it!=mainlist.end())
  26. {
  27. cout << *it << " ";
  28. it++;
  29. }
  30. cin >> check;
  31. cout << endl;
  32. list<string> :: iterator seeker=mainlist.begin();
  33. while (seeker!=mainlist.end())
  34. {
  35. seeker = find_if(seeker, mainlist.end(), func());
  36. if (func(*seeker)) cout << *seeker << " ";
  37. }
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement