c++ part. How does it work?

1 /******************************************************************************
2 * Uebungsblatt 4, Aufgabe 2 *
3 * Decodiert ein ASCII-Bild, das mit Laufl¨angencodierung komprimiert wurde. *
4 * Die codierte Darstellung ist im file "compressed.txt" enthalten, die *
5 * unkomprimierte Darstellung wird in der Konsole ausgegeben. *
6 * Autor: Fritz Muster, fmuster@student.ethz.ch *
7 * 10. M¨arz 2008 *
8 ******************************************************************************/
9 #include<iostream>
10 #include<fstream>
11 #include<string>
12 using namespace std;
13
14 int main() {
15 const int n = 1000;
16 int count[n], characters_per_line, counter, symbol_count=0;
17 char alphabet[n];
18
19 // read in the compressed representation
20 ifstream fin;
21 fin.open("compressed.txt");
22 if(fin.is_open()) {
23 fin>>characters_per_line;
24 while(!fin.eof() && (symbol_count < n)) {
25 fin >> count[symbol_count] >> alphabet[symbol_count];
26 symbol_count++;
27 }
28 } else {
29 cout<<"unable to open the file"<<endl;
30 }
31 fin.close();
32
33 // de-compress and output
34 // YOUR CODE COMES HERE
35
36 system("pause"); // only for Dev-C++
37 return 0;
38 }
Last edited on
What do you mean by "how does it work"?

Do you mean, "what does the program do"?
1
2
3
4
5
6
Exercise sheet 4, task 2
decodes a ASCII picture, which was compressed with Laufl¨angencodierung. 
the coded representation is contained in the file "compressed.txt", 
the uncompressed representation [is sent to the console]. 
author: Fritz sample, fmuster@student.ethz.ch 
March 10, 2008


Do you mean, "How can I make it work"?
I don't know. What is Laufl¨angencodierung? Can you explain it to us?

Or are you confused by a specific line?
What exactly are you haveing a problem with?
Topic archived. No new replies allowed.