diff --git a/selection_sort_c++/selection_sort.cpp b/selection_sort_c++/selection_sort.cpp new file mode 100644 index 00000000..030c0f29 --- /dev/null +++ b/selection_sort_c++/selection_sort.cpp @@ -0,0 +1,50 @@ +#include +#include +using namespace std; + +void selection_sort(vector seq); + +int main () { + vector seq; + int vector_dim; + int temp; + + cout << "This software sort a vector of integers using selection sort algorithm." << endl; + + cout << "Insert vector dimension: "; + cin >> vector_dim; + + if(vector_dim == 0) { + cout << "Invalid vector dimension" << endl; + return 0; + } + + cout << "Insert numbers separated by space: "; + + for(unsigned i=0; i> temp; + seq.push_back(temp); + } + + selection_sort(seq); +} + +void selection_sort(vector seq) { + for(unsigned i=0; i