Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Double Linked List - Programação 1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Leonardo Krambeck
Double Linked List - Programação 1
Commits
2cb37827
Commit
2cb37827
authored
5 years ago
by
Leonardo Krambeck
Browse files
Options
Downloads
Patches
Plain Diff
implementa ordena e arruma bug que estava em inicializa_lista
parent
b4486c15
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib_lista.c
+7
-6
7 additions, 6 deletions
lib_lista.c
lib_lista_complementar.c
+20
-11
20 additions, 11 deletions
lib_lista_complementar.c
main.c
+18
-2
18 additions, 2 deletions
main.c
with
45 additions
and
19 deletions
lib_lista.c
+
7
−
6
View file @
2cb37827
...
...
@@ -11,18 +11,22 @@ int inicializa_lista(t_lista *l)
if
(
sentinel
==
NULL
)
return
0
;
sentinel
->
prox
=
NULL
;
sentinel
->
prev
=
l
->
ini
;
l
->
ini
=
sentinel
;
sentinel
=
(
t_nodo
*
)
malloc
(
sizeof
(
t_nodo
));
if
(
sentinel
==
NULL
)
return
0
;
l
->
ini
->
prox
=
sentinel
;
sentinel
->
prox
=
NULL
;
sentinel
->
prev
=
l
->
ini
;
l
->
ini
->
prox
=
sentinel
;
l
->
fim
=
sentinel
;
l
->
atual
=
NULL
;
l
->
atual
=
NULL
;
l
->
tamanho
=
0
;
return
1
;
...
...
@@ -38,11 +42,8 @@ int lista_vazia(t_lista *l)
void
destroi_lista
(
t_lista
*
l
)
{
if
(
l
->
ini
==
NULL
&&
l
->
fim
==
NULL
&&
l
->
tamanho
==
0
)
{
printf
(
"This list is already destroyed.
\n
"
);
if
(
l
->
ini
==
NULL
&&
l
->
atual
==
NULL
&&
l
->
fim
==
NULL
&&
l
->
tamanho
==
0
)
return
;
}
t_nodo
*
p
;
...
...
This diff is collapsed.
Click to expand it.
lib_lista_complementar.c
+
20
−
11
View file @
2cb37827
...
...
@@ -54,19 +54,11 @@ int concatena_listas(t_lista *l, t_lista *c)
{
int
item
;
if
(
!
inicializa_atual_inicio
(
c
))
return
0
;
while
(
consulta_item_atual
(
&
item
,
c
))
{
while
(
remove_inicio_lista
(
&
item
,
c
))
if
(
!
insere_fim_lista
(
item
,
l
))
return
0
;
incrementa_atual
(
c
);
}
/* BUG
destroi_lista
(
c
);
*/
return
1
;
}
...
...
@@ -74,7 +66,24 @@ int concatena_listas(t_lista *l, t_lista *c)
Ordena a lista l em ordem crescente.
Retorna 1 se a operação foi bem sucedida e zero caso contrário.
*/
int
ordena_lista
(
t_lista
*
l
){
return
1
;}
int
ordena_lista
(
t_lista
*
l
)
{
t_lista
aux
;
if
(
!
inicializa_lista
(
&
aux
))
return
0
;
int
item
;
while
(
remove_fim_lista
(
&
item
,
l
))
if
(
!
insere_ordenado_lista
(
item
,
&
aux
))
return
0
;
if
(
!
copia_lista
(
&
aux
,
l
))
return
0
;
destroi_lista
(
&
aux
);
return
1
;
}
/*
Funcao que cria uma nova lista i pela intercalacao dos elementos
...
...
This diff is collapsed.
Click to expand it.
main.c
+
18
−
2
View file @
2cb37827
...
...
@@ -8,24 +8,40 @@ int main()
inicializa_lista
(
&
l
);
inicializa_lista
(
&
u
);
printf
(
"insere inicio e fim:
\n
"
);
insere_inicio_lista
(
10
,
&
l
);
insere_inicio_lista
(
20
,
&
l
);
insere_inicio_lista
(
5
,
&
l
);
insere_fim_lista
(
8
,
&
l
);
insere_fim_lista
(
12
,
&
l
);
insere_fim_lista
(
32
,
&
l
);
printf
(
"lista l: "
);
imprime_lista
(
&
l
);
printf
(
"
\n
"
);
printf
(
"
\n
\n
"
);
printf
(
"copia:
\n
"
);
copia_lista
(
&
l
,
&
u
);
printf
(
"lista u: "
);
imprime_lista
(
&
u
);
printf
(
"
\n
"
);
printf
(
"
\n
\n
"
);
printf
(
"concatena:
\n
"
);
concatena_listas
(
&
l
,
&
u
);
printf
(
"lista l: "
);
imprime_lista
(
&
l
);
printf
(
"
\n
"
);
printf
(
"lista u: "
);
imprime_lista
(
&
u
);
printf
(
"
\n\n
"
);
printf
(
"ordena:
\n
"
);
ordena_lista
(
&
l
);
printf
(
"lista l: "
);
imprime_lista
(
&
l
);
printf
(
"
\n
"
);
destroi_lista
(
&
l
);
destroi_lista
(
&
u
);
return
0
;
}
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