Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uff-Atividades-pilha-fila
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alan de Oliveira
uff-Atividades-pilha-fila
Commits
870cf896
Commit
870cf896
authored
May 11, 2022
by
Alan de Oliveira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrigindo Exercicio5
parent
46840fc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
31 deletions
+26
-31
exercicio5.cpp
exercicio5.cpp
+26
-31
No files found.
exercicio5.cpp
View file @
870cf896
...
@@ -84,42 +84,45 @@ class Pilha {
...
@@ -84,42 +84,45 @@ class Pilha {
template
<
class
T
>
Fila
<
T
>
inverterFila
(
Fila
<
T
>
fila
)
{
template
<
class
T
>
Fila
<
T
>
inverterFila
(
Fila
<
T
>
fila
)
{
Fila
<
T
>
filaAux
;
Fila
<
T
>
filaAux
,
filaInvertida
;
while
(
fila
.
frente
()
!=
-
1
)
{
T
ultimo
;
filaAux
.
enfilera
(
fila
.
desenfilera
());
bool
fim
=
false
;
while
(
!
fim
)
{
while
(
fila
.
frente
()
!=
-
1
)
{
ultimo
=
fila
.
frente
();
filaAux
.
enfilera
(
fila
.
desenfilera
());
}
filaInvertida
.
enfilera
(
ultimo
);
while
(
filaAux
.
frente
()
!=
-
1
&&
filaAux
.
frente
()
!=
ultimo
)
{
fila
.
enfilera
(
filaAux
.
desenfilera
());
}
filaAux
.
desenfilera
();
if
(
fila
.
frente
()
==
-
1
)
fim
=
true
;
}
}
return
fila
Aux
;
return
fila
Invertida
;
}
}
template
<
class
T
>
Fil
a
<
T
>
inverterFilaComPilha
(
Fila
<
T
>
fila
)
{
template
<
class
T
>
Pilh
a
<
T
>
inverterFilaComPilha
(
Fila
<
T
>
fila
)
{
Pilha
<
T
>
pilha
;
Pilha
<
T
>
pilha
;
while
(
fila
.
frente
()
!=
-
1
)
{
while
(
fila
.
frente
()
!=
-
1
)
{
pilha
.
empilha
(
fila
.
desenfilera
());
pilha
.
empilha
(
fila
.
desenfilera
());
}
}
printarPilha
(
pilha
,
"Fila invertida com Pilha"
);
//printarPilha(pilha, "Fila invertida com Pilha");
return
fila
;
}
template
<
class
T
>
Pilha
<
T
>
inverterPilhaComDuasPilhas
(
Pilha
<
T
>
pilha
)
{
return
pilha
;
}
Pilha
<
T
>
pilhaAux
,
pilhaAux2
;
while
(
pilha
.
topo
()
!=
-
1
)
{
pilhaAux
.
empilha
(
pilha
.
desempilha
());
}
while
(
pilhaAux
.
topo
()
!=
-
1
)
{
pilhaAux2
.
empilha
(
pilhaAux
.
desempilha
());
}
while
(
pilhaAux2
.
topo
()
!=
-
1
)
{
pilhaAux
.
empilha
(
pilhaAux2
.
desempilha
());
}
return
pilhaAux
;
}
void
preencherFila
(
Fila
<
char
>
&
fila
)
{
void
preencherFila
(
Fila
<
char
>
&
fila
)
{
...
@@ -182,16 +185,8 @@ int main(int argc, char* argv[]) {
...
@@ -182,16 +185,8 @@ int main(int argc, char* argv[]) {
printarFila
(
fila
,
"Fila invertida com outra fila ???"
);
printarFila
(
fila
,
"Fila invertida com outra fila ???"
);
preencherFila
(
fila
);
preencherFila
(
fila
);
inverterFilaComPilha
(
fila
);
Pilha
<
char
>
pilha
=
inverterFilaComPilha
(
fila
);
//printarFila(fila, "Fila invertida com Pilha");
printarPilha
(
pilha
,
"Fila invertida com Pilha"
);
/*
reencherFila(fila);
pilha = inverterPilhaComFila(pilha);
printarFila(fila, "Fila normal");
reencherFila(fila);
pilha = inverterPilhaComDuasPilhas(pilha);
printarFila(fila, "Fila normal");*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment