From a7fdef088b20fc42c487d5edcbbf24c3b5dff0b8 Mon Sep 17 00:00:00 2001 From: priyanshu666 <55185263+priyanshu666@users.noreply.github.com> Date: Tue, 8 Oct 2019 02:27:22 +0530 Subject: [PATCH 1/2] Added selection sort added a program to demonstrate selection sort in c++ --- selection-sort.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 selection-sort.cpp diff --git a/selection-sort.cpp b/selection-sort.cpp new file mode 100644 index 0000000..2552914 --- /dev/null +++ b/selection-sort.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; +void selectionsort(int [], int); +void swap(int*, int*); +void getArray(int [], int); +int main() //Driver code +{ + int arr[] = {-2, 6, 28, 13, 16, 11}; + int n = 6; + selectionsort(arr, n); + cout<<"Sorted Array:\n"; + getArray(arr, n); + return 0; +} +void swap(int *x, int *y) //Function to swap the elements +{ + int temp; + temp = *x; + *x = *y; + *y = temp; +} +void selectionsort(int arr1[], int sz) //Selection sort function +{ + int i, j, small; + for (i = 0; i Date: Tue, 8 Oct 2019 02:27:46 +0530 Subject: [PATCH 2/2] Update selection-sort.cpp --- selection-sort.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/selection-sort.cpp b/selection-sort.cpp index 2552914..03eaa48 100644 --- a/selection-sort.cpp +++ b/selection-sort.cpp @@ -42,8 +42,3 @@ void getArray(int A[], int size) //Function to display the array cout<