From 8f0fbf401c1188afac8b115d56ba390b8838608a Mon Sep 17 00:00:00 2001 From: abhisheksaxena1998 <44598815+abhisheksaxena1998@users.noreply.github.com> Date: Tue, 30 Oct 2018 13:57:23 +0530 Subject: [PATCH] Create sortwithtemplatebubblesort Program to sort using templates --- sortwithtemplatebubblesort | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sortwithtemplatebubblesort diff --git a/sortwithtemplatebubblesort b/sortwithtemplatebubblesort new file mode 100644 index 0000000..e5d9d9f --- /dev/null +++ b/sortwithtemplatebubblesort @@ -0,0 +1,44 @@ +#include +#include +#include +using namespace std; +template//standard template library +void sort(T a[],int s)//sorts in descending order +{ + T temp; + for (int i=0;ia[j]) + { + temp=a[j+1]; + a[j+1]=a[j]; + a[j]=temp; + } + } + } +} +int main() +{ + int s; + int b[100]; + char c[100]; + cout<<"Enter the number of values to be sorted"<>s; + cout<<"Enter the array of integers"<>b[i]; + } + sort(b,s);//calls the sort function that sorts with templates + for (int i=0;i