Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void out(int num, char last) {
- if (num > 4 || last == '#') {
- std::cout << "#" << last << std::hex << num << "#";
- } else {
- while(num--) {
- std::cout << last;
- }
- }
- }
- int main()
- {
- char last;
- char cur;
- int num = 1;
- if (!std::cin.get(last)) {
- return 0;
- }
- while (std::cin.get(cur)) {
- if (cur == last) {
- ++num;
- } else {
- out(num, last);
- num = 1;
- }
- last = cur;
- }
- out(num, last);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement