From f35f97aa69358a76327be8c6fa68cb920505e4f0 Mon Sep 17 00:00:00 2001 From: combermere246 Date: Thu, 13 Sep 2018 15:02:52 -0400 Subject: [PATCH 01/10] Data.h --- Data.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ Data.h | 28 ++++++++++++++++++++++++++++ main.cpp | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 Data.cpp create mode 100644 Data.h create mode 100644 main.cpp diff --git a/Data.cpp b/Data.cpp new file mode 100644 index 0000000..b2d70b7 --- /dev/null +++ b/Data.cpp @@ -0,0 +1,40 @@ +#include +#include +#include "Data.h" + +using namespace std; + +class Data +{ + + public; + + Data::Data() + { + x=0; + y=0.0; + } + + Data::Data(int a, float b) + { + x=a; + y=b; + } + Data::float getY() + { + return y; + } + Data::int getX() + { + return x; + } + Data::void setX(int a) + { + x=a; + } + Data::void setY(float a) + { + y=a; + } + +}; diff --git a/Data.h b/Data.h new file mode 100644 index 0000000..33f1549 --- /dev/null +++ b/Data.h @@ -0,0 +1,28 @@ +#ifndef DATA_H +#define DATA_H + +#include +#include + +using namespace std; + +class Data +{ + private: + + int x; + float y; + + public: + + Data(); + Data(int a, float b); + float getY(); + int getX(); + void setX(int a); + void setY(float a); + + +}; + +#endif diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3d0ee30 --- /dev/null +++ b/main.cpp @@ -0,0 +1,37 @@ +#include +#include +#include "Data.h" + +using namespace std; + +{ + + vector v1; + vector v2={5,8,22} + v1.push_back(17); + cout << "V2 has " << v2.size() << "elements" << endl; + + for (auto x:v2) + { + cout << x << endl; + } + + Data d0; + Data d1 = {7,24.83}; + d0.setX(15); + d0.setY(3.14); + + vector v; + v.push_back( {7,21.01} ); + v.push_back(d); + d.setX(10); + d.setY(12.10); + v.push_back(d); + + for (auto a:v) + { + cout << a.getx() << " "; + cout << a.getY() << endl; + return 0; + +} From 9e72c199ca8d88cde6c676e6bd22f57b17a6006a Mon Sep 17 00:00:00 2001 From: combermere246 <42950600+combermere246@users.noreply.github.com> Date: Thu, 13 Sep 2018 18:54:30 -0300 Subject: [PATCH 02/10] Update Data.cpp --- Data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data.cpp b/Data.cpp index b2d70b7..811f218 100644 --- a/Data.cpp +++ b/Data.cpp @@ -7,7 +7,7 @@ using namespace std; class Data { - public; + public: Data::Data() { From 41e13247a3f5b3aed73c3632e081507cbccded2f Mon Sep 17 00:00:00 2001 From: combermere246 <42950600+combermere246@users.noreply.github.com> Date: Thu, 13 Sep 2018 18:55:26 -0300 Subject: [PATCH 03/10] Update main.cpp --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 3d0ee30..8efc6ad 100644 --- a/main.cpp +++ b/main.cpp @@ -7,7 +7,7 @@ using namespace std; { vector v1; - vector v2={5,8,22} + vector v2={5,8,22}; v1.push_back(17); cout << "V2 has " << v2.size() << "elements" << endl; From a263bed79f99ef7187e1288f638822d036a121c4 Mon Sep 17 00:00:00 2001 From: combermere246 <42950600+combermere246@users.noreply.github.com> Date: Thu, 13 Sep 2018 19:35:43 -0300 Subject: [PATCH 04/10] Update Data.cpp --- Data.cpp | 61 +++++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/Data.cpp b/Data.cpp index 811f218..d28f7d1 100644 --- a/Data.cpp +++ b/Data.cpp @@ -1,40 +1,33 @@ #include -#include #include "Data.h" using namespace std; -class Data + +Data::Data() +{ +x=0; +y=0.0; +} + +Data::Data(int a, float b) +{ +x=a; +y=b; +} +float Data::getY() +{ +return y; +} +int Data::getX() +{ +return x; +} +void Data::setX(int a) +{ +x=a; +} +void Data::setY(float a) { - - public: - - Data::Data() - { - x=0; - y=0.0; - } - - Data::Data(int a, float b) - { - x=a; - y=b; - } - Data::float getY() - { - return y; - } - Data::int getX() - { - return x; - } - Data::void setX(int a) - { - x=a; - } - Data::void setY(float a) - { - y=a; - } - -}; +y=a; +} From e57a08c9ffce847d8038c8df48bbf52641f32577 Mon Sep 17 00:00:00 2001 From: combermere246 <42950600+combermere246@users.noreply.github.com> Date: Thu, 13 Sep 2018 19:36:36 -0300 Subject: [PATCH 05/10] Update Data.h --- Data.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Data.h b/Data.h index 33f1549..3d8b797 100644 --- a/Data.h +++ b/Data.h @@ -8,21 +8,21 @@ using namespace std; class Data { - private: - - int x; - float y; - - public: - - Data(); - Data(int a, float b); - float getY(); - int getX(); - void setX(int a); - void setY(float a); - - +private: + +int x; +float y; + +public: + +Data(); +Data(int a, float b); +float getY(); +int getX(); +void setX(int a); +void setY(float a); + + }; #endif From 547a6a96dc42baee7b557cb48504f2d34b4d05b4 Mon Sep 17 00:00:00 2001 From: combermere246 <42950600+combermere246@users.noreply.github.com> Date: Thu, 13 Sep 2018 19:37:36 -0300 Subject: [PATCH 06/10] Update main.cpp --- main.cpp | 64 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/main.cpp b/main.cpp index 8efc6ad..4f4471b 100644 --- a/main.cpp +++ b/main.cpp @@ -4,34 +4,40 @@ using namespace std; +int main() + +{ + +vector v1; +vector v2={5,8,22}; +v1.push_back(17); +cout << "V2 has " << v2.size() << " elements. They are:" << endl< v; +v.push_back( {7,21.01} ); +Data d; +v.push_back(d); +d.setX(10); +d.setY(12.10); +v.push_back(d); + +cout < v1; - vector v2={5,8,22}; - v1.push_back(17); - cout << "V2 has " << v2.size() << "elements" << endl; - - for (auto x:v2) - { - cout << x << endl; - } - - Data d0; - Data d1 = {7,24.83}; - d0.setX(15); - d0.setY(3.14); - - vector v; - v.push_back( {7,21.01} ); - v.push_back(d); - d.setX(10); - d.setY(12.10); - v.push_back(d); - - for (auto a:v) - { - cout << a.getx() << " "; - cout << a.getY() << endl; - return 0; - +cout << a.getX() << " "; +cout << a.getY() << endl<< endl; +} +return 0; + } From 2093ed114ecb7386336915a89b4cf4058a3f9c7f Mon Sep 17 00:00:00 2001 From: combermere246 Date: Thu, 13 Sep 2018 19:06:35 -0400 Subject: [PATCH 07/10] Data.h --- Data.cpp | 14 ++++---------- main.cpp | 14 ++++++++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Data.cpp b/Data.cpp index b2d70b7..8953d51 100644 --- a/Data.cpp +++ b/Data.cpp @@ -1,13 +1,8 @@ #include -#include #include "Data.h" using namespace std; -class Data -{ - - public; Data::Data() { @@ -20,21 +15,20 @@ class Data x=a; y=b; } - Data::float getY() + float Data::getY() { return y; } - Data::int getX() + int Data::getX() { return x; } - Data::void setX(int a) + void Data::setX(int a) { x=a; } - Data::void setY(float a) + void Data::setY(float a) { y=a; } -}; diff --git a/main.cpp b/main.cpp index 3d0ee30..c37f0a3 100644 --- a/main.cpp +++ b/main.cpp @@ -4,12 +4,14 @@ using namespace std; +int main() + { vector v1; - vector v2={5,8,22} + vector v2={5,8,22}; v1.push_back(17); - cout << "V2 has " << v2.size() << "elements" << endl; + cout << "V2 has " << v2.size() << " elements. They are:" << endl< v; v.push_back( {7,21.01} ); + Data d; v.push_back(d); d.setX(10); d.setY(12.10); v.push_back(d); + cout < Date: Thu, 13 Sep 2018 19:35:36 -0400 Subject: [PATCH 08/10] Data.h --- Data.cpp | 33 +-------------------------------- main.cpp | 35 ----------------------------------- 2 files changed, 1 insertion(+), 67 deletions(-) diff --git a/Data.cpp b/Data.cpp index be7b3de..3ea685f 100644 --- a/Data.cpp +++ b/Data.cpp @@ -3,37 +3,6 @@ using namespace std; -<<<<<<< HEAD - - Data::Data() - { - x=0; - y=0.0; - } - - Data::Data(int a, float b) - { - x=a; - y=b; - } - float Data::getY() - { - return y; - } - int Data::getX() - { - return x; - } - void Data::setX(int a) - { - x=a; - } - void Data::setY(float a) - { - y=a; - } - -======= Data::Data() { @@ -62,4 +31,4 @@ void Data::setY(float a) { y=a; } ->>>>>>> 547a6a96dc42baee7b557cb48504f2d34b4d05b4 + diff --git a/main.cpp b/main.cpp index a970772..b37e32d 100644 --- a/main.cpp +++ b/main.cpp @@ -41,39 +41,4 @@ int main() } return 0; -======= -{ - -vector v1; -vector v2={5,8,22}; -v1.push_back(17); -cout << "V2 has " << v2.size() << " elements. They are:" << endl< v; -v.push_back( {7,21.01} ); -Data d; -v.push_back(d); -d.setX(10); -d.setY(12.10); -v.push_back(d); - -cout < Date: Wed, 19 Sep 2018 21:46:59 -0400 Subject: [PATCH 09/10] Data.h --- main.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index b37e32d..412ea74 100644 --- a/main.cpp +++ b/main.cpp @@ -4,14 +4,51 @@ using namespace std; +void print (auto A) +{ + for (auto a : A) + cout << a << " "; + + cout< 0 and D[j] < D[j-1]) + { + swap (D[j], D[j-1]); + j--; + } + print(D); + + } +} + int main() { vector v1; - vector v2={5,8,22}; + vector v2={22,8,7,9,45}; v1.push_back(17); + + vector w = {7, 4, 2, 19, 31, 11}; + + insertionSort(w); + + for (auto i:w) + { + cout << i << " "; + } + + + cout < Date: Thu, 20 Sep 2018 14:22:38 -0400 Subject: [PATCH 10/10] Data.h --- main.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 412ea74..8ed806b 100644 --- a/main.cpp +++ b/main.cpp @@ -12,6 +12,13 @@ void print (auto A) cout< 0 and D[j].getX() < D[j-1].getX()) + { + swap (D[j], D[j-1]); + j--; + } + printClass(D); + + } +} + int main() @@ -37,7 +59,7 @@ int main() vector v2={22,8,7,9,45}; v1.push_back(17); - vector w = {7, 4, 2, 19, 31, 11}; + vector w = {7, 6, 5, 4, 3, 2}; insertionSort(w); @@ -67,9 +89,12 @@ int main() v.push_back( {7,21.01} ); Data d; v.push_back(d); - d.setX(10); + d.setX(6); d.setY(12.10); v.push_back(d); + d.setX(5); + d.setY(6.12); + v.push_back(d); cout <