-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
101 lines (78 loc) · 2.27 KB
/
main.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
using namespace std;
#include "../include/Vertex.h"
#include "../include/BubbleSort.h"
#include "../include/SelectionSort.h"
#include "../include/InsertionSort.h"
#include "../include/QuickSort.h"
#include "../include/MergeSort.h"
#include "../include/HeapSort.h"
#include "../include/ShellSort.h"
#include "../include/ShellSortForInt.h"
#include "../include/Check.h"
int main() {
char metodoOrdenacao;
int numVertices;
cin >> metodoOrdenacao >> numVertices;
Vertex graph[numVertices];
for (int i = 0; i < numVertices; ++i) {
int numNeighbors;
std::cin >> numNeighbors;
graph[i].index = i;
graph[i].neighbors = new int[numNeighbors];
graph[i].numNeighbors = numNeighbors;
for (int j = 0; j < numNeighbors; ++j) {
int neighbor;
std::cin >> neighbor;
graph[i].neighbors[j] = neighbor;
}
}
int colors[numVertices];
for (int i = 0; i < numVertices; ++i) {
int cor;
std::cin >> cor;
graph[i].color = cor;
colors[i] = cor;
}
for (int i = 0; i < numVertices; ++i) {
Vertex item = graph[i];
int numNeighbors = item.numNeighbors;
graph[i].pointNeighbors = new Vertex[numNeighbors];
for (int j = 0; j < numNeighbors; ++j) {
Vertex neighbor = graph[item.neighbors[j]];
graph[i].pointNeighbors[j] = neighbor;
}
}
ShellSortForInt(colors, numVertices);
for (int i = 1; i < numVertices; ++i) {
if(colors[i] - colors[i-1] > 1){
cout << 0 << endl;
return 0;
}
}
switch (metodoOrdenacao) {
case 'b':
BubbleSort(graph, numVertices);
break;
case 's':
SelectionSort(graph, numVertices);
break;
case 'i':
InsertionSort(graph, numVertices);
break;
case 'q':
QuickSort(graph, numVertices);
break;
case 'm':
MergeSort(graph, numVertices);
break;
case 'p':
HeapSort(graph, numVertices);
break;
case 'y':
ShellSort(graph, numVertices);
break;
}
Check(graph, numVertices);
return 0;
}