Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. void compress(istream* in, ostream* out) {
  2. long long X = 1;
  3.  
  4. while (!in->eof()) {
  5. int Y = in->get();
  6.  
  7. if (X >= LLONG_MAX/(Y * 9) || Y == -1) {
  8. out->put(X);
  9. X = 1;
  10. } else {
  11. X = Y * X * 9;
  12. }
  13.  
  14. if (Y == -1) break;
  15.  
  16. cout << "X " << X << endl;
  17. }
  18. }
  19.  
  20. void decompress(istream* in, ostream* out) {
  21. long long X = 1;
  22.  
  23. while (!in->eof()) {
  24. X = in->get();
  25. for (int i = X; i >= 1; i--) {
  26. for (int j=0; j<=255; j++) {
  27. if (9*i*j == X) {
  28. out->put(j);
  29. X=i;
  30. }
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement