#include #include using namespace std; int main () { ifstream in("encoding.in"); char s, o; int c; bool ncs = false; s = in.get(); o = s; while(!in.eof()) { c = 1; if (o == '\n') { s = in.get(); if(in.eof() && ncs) cout << 1; cout << o; } else { while((s = in.get()) == o) { c++; } if(c > 1) { if(ncs) { cout << 1; ncs = false; } while(c > 9) { cout << 9 << o; c -= 9; } cout << c << o; } if(c == 1) { if (!ncs) { cout << 1; ncs = true; } if (o == '1') { cout << 1; } cout << o; } } o = s; } return 0; }