-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
75 lines (70 loc) · 1.86 KB
/
Main.cpp
File metadata and controls
75 lines (70 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* Leonardo Pinheiro de Souza - 32127391
Matheus Farias de Oliveira Matsumoto - 32138271
Código em Inglês
Comentários em Portugês-BR
Referências:
https://www.youtube.com/watch?v=ScKTk5GwmG4&ab_channel=NesoAcademy
https://www.youtube.com/watch?v=HKfj0l7ndbc&t=939s
https://www.youtube.com/watch?v=m7rrk65GiXY&t=276s
https://docs.microsoft.com/pt-br/visualstudio/debugger/how-can-i-debug-an-access-violation-q?view=vs-2022
https://www.geeksforgeeks.org/program-to-implement-singly-linked-list-in-c-using-class/
*/
// main.cpp
#include <iostream>
#include <clocale>
#include "LinkedList.h"
using namespace std;
void Print(LinkedList& list)
{
Node* current = list.GetHead();
while (current != nullptr) {
cout << current->data << " ";
current = current->next;
}
}
void PrintListInfo(LinkedList list)
{
if (list.IsEmpty() == true)
{
cout << "\nLista vazia!\n";
}
else
{
cout << "\nLista: ";
Print(list);
}
}
int main()
{
LinkedList list;
setlocale(LC_CTYPE, "Portuguese");
std::cout << "*** Lista Ligada/Encadeada (Linked List) ***\n";
PrintListInfo(list);
list.Insert(1);
list.Insert(2);
list.Insert(3);
list.Append(4);
list.Append(5);
list.Append(6);
PrintListInfo(list);
list.Clear();
PrintListInfo(list);
list.Insert(77);
list.Append(88);
list.Insert(99);
list.Append(3);
list.Insert(2);
list.Append(1);
list.Insert(0);
PrintListInfo(list);
Node* removed = list.RemoveNode(3);
std::cout << "\nNó removido: " << removed->data << '\n';
PrintListInfo(list);
removed = list.RemoveHead();
std::cout << "\nNó removido: " << removed->data << '\n';
PrintListInfo(list);
removed = list.RemoveTail();
std::cout << "\nNó removido: " << removed->data << '\n';
PrintListInfo(list);
std::cout << "\nFim.\n";
}