Vlad5080

mapовый разлелитель двоичного кода

Feb 2nd, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string input, buff = "";
  11. map<string, bool> blocks;
  12. vector<string> output;
  13. getline(cin, input);
  14. for (int i = 0; i < input.size(); i++)
  15. {
  16. buff += input[i];
  17. if (!blocks[buff])
  18.  
  19. {
  20. blocks[buff] = true;
  21. output.push_back(buff);
  22. buff = "";
  23. }
  24. else if (i == input.size() - 1)
  25. {
  26. output.push_back(buff);
  27. }
  28. }
  29. for (int i = 0; i < output.size(); i++)
  30. {
  31. cout << output[i] << ' ';
  32. }
  33. return 0;
  34. }
Add Comment
Please, Sign In to add comment