aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2020-05-30 03:26:25 +0000
committerrepl.it user2020-05-30 03:26:25 +0000
commit6fc4521ec41f190eca423acab65ef20e9b347cab (patch)
tree79821e9b4bfa85d9dde408127161e45d247f1072
parentfbd1d1905864ec04dad55ff7d8ec9cef75a918ff (diff)
Update main.cpp
-rw-r--r--src/main.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index e22b414..55224da 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -368,16 +368,15 @@ int main() {
string s = output.gettextstring(-100000);
for (auto& c : s) if (c == '\r') c = ' ';
s = huffmancompress(s);
- printf("%s\n", s.c_str());
-
-
-
- /*int final_ratio = 10, orig_size = 0;
+ int orig_size = 0;
ifstream testin(input_file);
char c;
while (testin >> c) ++orig_size;
- while (10 * ans.size() > final_ratio * orig_size) ans.pop_back();
- cout << ans;*/
+ while (100 * s.size() > compressrate * orig_size) s.pop_back();
+ cout << "Original length: " << orig_size << '\n';
+ cout << "Compressed length: " << s.size() << '\n';
+ cout << "Percent compression: " << 100.0 - ((double)100.0 * s.size() / orig_size) << "%\n";
+ printf("%s\n", s.c_str());
// WARNING: Huffman will CRASH if you pass a string with only one unique character