Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
redes1-trabalho3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Machado
redes1-trabalho3
Commits
dd009b50
Commit
dd009b50
authored
9 years ago
by
Eduardo Machado
Browse files
Options
Downloads
Patches
Plain Diff
conversão
parent
24a49101
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/lzw.h
+1
-1
1 addition, 1 deletion
include/lzw.h
src/lzw.cpp
+16
-14
16 additions, 14 deletions
src/lzw.cpp
with
17 additions
and
15 deletions
include/lzw.h
+
1
−
1
View file @
dd009b50
...
...
@@ -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
This diff is collapsed.
Click to expand it.
src/lzw.cpp
+
16
−
14
View file @
dd009b50
...
...
@@ -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
[]){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment