Skip to content
Snippets Groups Projects
Commit dd009b50 authored by Eduardo Machado's avatar Eduardo Machado
Browse files

conversão

parent 24a49101
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,6 @@
class LZW{
public:
string pack(string &input);
int* pack(string &input);
string unpack(int input[]);
};
\ No newline at end of file
......@@ -5,11 +5,13 @@
using namespace std;
string LZW::pack(string &input){
int* LZW::pack(string &input){
map<string, int> dictionary;
string output = "";
string nextChar, currentChar = "";
int i, cont=0, dictionarySize = 256;
int i, temp, n, lastI, cont=0, dictionarySize = 256;
int *intOutput;
intOutput = new int[dictionarySize-1];
//inicializa o dicionário
for(i = 0; i < 256; i++){
......@@ -31,25 +33,25 @@ string LZW::pack(string &input){
output += dictionary[currentChar] + " ";
cont++;
/* CONVERSAO
int *intOutput;
int temp = n = 0;
intOutput = new int[dictionarySize-1];
// --------------------- CONVERSAO --------------------------
for(i = 0; i < cont; i++){
if(output[i] != " "){
do{
if(output[i] != ' ' && output[i] != '\0'){
temp++;
} else {
for (j = temp-1; j >= 0; j--){
intOutput[n] += output[j] * pow(10,j);
for (j = lastI; j < i; j++){
intOutput[n] += (output[j] - '0') * pow(10,temp-1);
temp--;
}
n++;
temp = 0;
}
lastI = i+1;
}
*/
i++;
}while (output[i-1] != '\0');
//-----------------------------------------------------------
return intOutput;
return &intOutput;
}
string LZW::unpack(int input[]){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment