Advertisement
selfpromise

list №9

Jan 21st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. list<char> l;
  9. list<char>::iterator it;
  10.  
  11. char c;
  12. while (cin >> c) {
  13. if (c == '.') {
  14. break;
  15. }
  16. else {
  17. l.push_back(c);
  18. }
  19. }
  20.  
  21. it = l.begin();
  22. while (it != l.end())
  23. {
  24. if (*it == '#')
  25. {
  26. it = l.erase(it);
  27. if (it != l.begin())
  28. {
  29. it--;
  30. it = l.erase(it);
  31. if (it != l.begin())
  32. {
  33. it--;
  34. }
  35. }
  36. }
  37. else {
  38. it++;
  39. }
  40. }
  41.  
  42. for (it = l.begin(); it != l.end(); it++) {
  43. cout << *it;
  44. }
  45. }
  46.  
  47. /**
  48. #######1#23##HE345###LL06783####
  49. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement