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
91127488
Commit
91127488
authored
Jun 12, 2022
by
Alan de Oliveira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comentando exercicio 2
parent
5605ae38
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
exercicio2.cpp
exercicio2.cpp
+26
-0
No files found.
exercicio2.cpp
View file @
91127488
...
@@ -55,16 +55,39 @@ class Fila {
...
@@ -55,16 +55,39 @@ class Fila {
};
};
/**
* @brief Reescreva as operações de uma pilha utilizando uma fila
*
* As operações serão descritas abaixo
*
* @tparam T
*/
template
<
class
T
>
template
<
class
T
>
class
Pilha
{
class
Pilha
{
public
:
public
:
/**
* @brief
* O empilhamento é o mesmo enfileiramento
*
* @param elemento
*/
void
empilha
(
T
elemento
)
{
void
empilha
(
T
elemento
)
{
if
(
fila
==
nullptr
)
if
(
fila
==
nullptr
)
fila
=
new
Fila
<
T
>
();
fila
=
new
Fila
<
T
>
();
fila
->
enfilera
(
elemento
);
fila
->
enfilera
(
elemento
);
}
}
/**
* @brief
* Para desempilhar, eu crio uma nova fila passo todos os elementos
* para ela, exceto o último elemento. e faço o delete na antiga fila.
*
* @return T
*/
T
desempilha
()
{
T
desempilha
()
{
if
(
fila
->
frente
()
==
-
1
)
if
(
fila
->
frente
()
==
-
1
)
...
@@ -81,6 +104,9 @@ class Pilha {
...
@@ -81,6 +104,9 @@ class Pilha {
return
elemento
;
return
elemento
;
}
}
T
topo
()
{
return
fila
->
frente
();
}
private
:
private
:
Fila
<
T
>
*
fila
=
new
Fila
<
T
>
();
Fila
<
T
>
*
fila
=
new
Fila
<
T
>
();
...
...
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