Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <fstream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. ifstream input;
  11. input.open("input.txt");
  12. string s;
  13. set <string> strs;
  14. set <string> ans;
  15. while (!input.eof()) {
  16. input >> s;
  17. if (s == "") {
  18. continue;
  19. }
  20. if (s[s.size() - 1] != '!' && s[s.size() - 1] != '?' && s[s.size() - 1] != '.') {
  21. s[0] = tolower(s[0]);
  22. strs.insert(s);
  23. }
  24. else {
  25. strs.insert(s.substr(0, s.size() - 1));
  26. if (s[s.size() - 1] == '!' || s[s.size() - 1] == '?') {
  27. for (set<string>::iterator it = strs.begin(); it != strs.end(); it++) {
  28. string temp = *it;
  29. ans.insert(temp);
  30. }
  31. }
  32. strs.clear();
  33. }
  34. }
  35. for (set<string>::iterator it = ans.begin(); it != ans.end(); it++) {
  36. cout << *it << " ";
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement