-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorSort.cpp
More file actions
71 lines (68 loc) · 1.61 KB
/
VectorSort.cpp
File metadata and controls
71 lines (68 loc) · 1.61 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
// VectorSort.cpp : main project file.
//#include "stdafx.h"
/*#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>*/
#include <iostream>
#include "vectorClass.h"
#include "person.h"
#include <cstdlib>
#include <exception>
using namespace std;
int main()
{
//create some vectors
vectorClass<int> aVector;
vectorClass<person> anotherVector;
//populate those vectors
aVector.insert(5);
aVector.insert(3);
aVector.insert(9);
aVector.insert(1);
aVector.insert(15);
aVector.insert(2);
aVector.insert(4);
aVector.insert(6);
aVector.insert(10);
aVector.insert(8);
aVector.insert(11);
aVector.insert(14);
aVector.insert(12);
aVector.insert(13);
aVector.insert(7);
anotherVector.insert(person("Bobby", 74));
anotherVector.insert(person("Toni", 23));
anotherVector.insert(person("Jez", 27));
anotherVector.insert(person("Marc", 28));
anotherVector.insert(person("Jonas", 99));
anotherVector.insert(person("Art", 44));
anotherVector.insert(person("Carl", 11));
anotherVector.insert(person("Vinny", 55));
anotherVector.insert(person("Rory", 49));
anotherVector.insert(person("Elijah", 8));
anotherVector.insert(person("Tony", 11));
//display unsorted vectors
for (int i=0; i<(aVector.size()); i++)
{
cout<<aVector[i]<<" ";
}
cout<<endl;
for (int i=0; i<(anotherVector.size()); i++)
{
cout<<anotherVector[i];
}
//sort the vectors
anotherVector.insertionSort();
aVector.quickSort(0,aVector.size()-1);
//display sorted vectors
for (int i=0; i<(aVector.size()); i++)
{
cout<<aVector[i]<<" ";
}
cout<<endl;
for (int i=0; i<(anotherVector.size()); i++)
{
cout<<anotherVector[i];
}
return 0;
}