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
2ceb5fdd
Commit
2ceb5fdd
authored
5 years ago
by
Leonardo Krambeck
Browse files
Options
Downloads
Patches
Plain Diff
arruma remove inicio e implementa remove fim
parent
07c3a1fb
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
lib_lista.c
+24
-12
24 additions, 12 deletions
lib_lista.c
main.c
+11
-7
11 additions, 7 deletions
main.c
with
35 additions
and
19 deletions
lib_lista.c
+
24
−
12
View file @
2ceb5fdd
...
...
@@ -132,10 +132,6 @@ int insere_ordenado_lista(int item, t_lista *l)
return
1
;
}
/*
Remove o primeiro elemento da lista e o retorna em *item.
Retorna 1 se a operação foi bem sucedida e zero caso contrário.
*/
int
remove_inicio_lista
(
int
*
item
,
t_lista
*
l
)
{
if
(
lista_vazia
(
l
))
...
...
@@ -144,10 +140,11 @@ int remove_inicio_lista(int *item, t_lista *l)
return
0
;
}
t_nodo
*
p
=
l
->
ini
;
t_nodo
*
p
=
l
->
ini
->
prox
;
l
->
ini
=
p
->
prox
;
p
->
prox
->
prev
=
l
->
ini
;
p
->
prev
->
prox
=
p
->
prox
;
p
->
prox
->
prev
=
p
->
prev
;
*
item
=
p
->
chave
;
free
(
p
);
...
...
@@ -156,11 +153,26 @@ int remove_inicio_lista(int *item, t_lista *l)
return
1
;
}
/*
Remove o último elemento da lista e o retorna em *item.
Retorna 1 se a operação foi bem sucedida e zero caso contrário.
*/
int
remove_fim_lista
(
int
*
item
,
t_lista
*
l
){
return
1
;}
int
remove_fim_lista
(
int
*
item
,
t_lista
*
l
)
{
if
(
lista_vazia
(
l
))
{
item
=
NULL
;
return
0
;
}
t_nodo
*
p
=
l
->
fim
->
prev
;
p
->
prev
->
prox
=
p
->
prox
;
p
->
prox
->
prev
=
p
->
prev
;
*
item
=
p
->
chave
;
free
(
p
);
l
->
tamanho
--
;
return
1
;
}
/*
Se o elemento chave existir na lista, o retorna em *item.
...
...
This diff is collapsed.
Click to expand it.
main.c
+
11
−
7
View file @
2ceb5fdd
...
...
@@ -3,6 +3,8 @@
#include
"lib_lista.h"
void
imprime
(
t_lista
*
l
)
{
if
(
!
lista_vazia
(
l
))
{
t_nodo
*
p
=
l
->
ini
->
prox
;
...
...
@@ -13,6 +15,7 @@ void imprime (t_lista *l)
}
printf
(
"%d
\n
"
,
p
->
chave
);
}
}
int
main
()
{
...
...
@@ -26,7 +29,8 @@ int main ()
insere_ordenado_lista
(
3
,
&
l
);
insere_ordenado_lista
(
2
,
&
l
);
imprime
(
&
l
);
remove_inicio_lista
(
&
item
,
&
l
);
remove_fim_lista
(
&
item
,
&
l
);
remove_fim_lista
(
&
item
,
&
l
);
imprime
(
&
l
);
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