Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void compress(istream* in, ostream* out) {
- long long X = 1;
- while (!in->eof()) {
- int Y = in->get();
- if (X >= LLONG_MAX/(Y * 9) || Y == -1) {
- out->put(X);
- X = 1;
- } else {
- X = Y * X * 9;
- }
- if (Y == -1) break;
- cout << "X " << X << endl;
- }
- }
- void decompress(istream* in, ostream* out) {
- long long X = 1;
- while (!in->eof()) {
- X = in->get();
- for (int i = X; i >= 1; i--) {
- for (int j=0; j<=255; j++) {
- if (9*i*j == X) {
- out->put(j);
- X=i;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement