aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2020-05-30 03:22:03 +0000
committerrepl.it user2020-05-30 03:22:03 +0000
commitfbd1d1905864ec04dad55ff7d8ec9cef75a918ff (patch)
treeb12f9cdf76bdd527419f836bbb04ca7eafd188b1
parent115f31e0af39bfb18c7bf36700565942dd41d742 (diff)
Fixed some bugs
-rw-r--r--.replit2
-rw-r--r--src/main.cpp6
2 files changed, 5 insertions, 3 deletions
diff --git a/.replit b/.replit
index 74b6de4..b9a1fe1 100644
--- a/.replit
+++ b/.replit
@@ -1,2 +1,2 @@
language = "cpp"
-run = "g++ src/*.cpp -o compress -std=c++1y; echo \"Compilation done\n\"; ./compress"
+run = "g++ src/*.cpp -o compress -std=c++1y; echo Compilation done; ./compress"
diff --git a/src/main.cpp b/src/main.cpp
index 0bfdda1..e22b414 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -301,10 +301,11 @@ string huffmancompress(string s)
for (int i = 0; i < ((int)enc.size() + 7) / 8; ++i) {
char out = 0;
for (int j = i; j < min(i + 8, (int)enc.size()); ++j) {
- if (enc[j]) i += (1 << (j - i));
+ if (enc[j]) out += (1 << (j - i));
}
ans += out;
}
+ return ans;
}
int initsize=0;
@@ -366,7 +367,8 @@ int main() {
output.preprocess(-1);
string s = output.gettextstring(-100000);
for (auto& c : s) if (c == '\r') c = ' ';
- //printf("%s\n", s.c_str());
+ s = huffmancompress(s);
+ printf("%s\n", s.c_str());