Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- int
- main(void)
- {
- std::cout.unsetf(std::ios::dec);
- std::cout.setf(std::ios::hex);
- constexpr int MAX_CHAR = 4;
- int ch = std::cin.get();
- while (ch != EOF) {
- int old = ch;
- int count = 1;
- while (old == (ch = std::cin.get())) {
- ++count;
- }
- if (old == '#' or count > MAX_CHAR) {
- std::cout << '#' << char(old) << count << '#';
- } else {
- while (count-- > 0) {
- std::cout << char(old);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement