-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.cpp
64 lines (64 loc) · 1.34 KB
/
temp.cpp
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
#include<iostream>
#include<conio.h>
using namespace std;
int n,i,j,s=100;
template<class t>
void selection(t arr[100])
{
int min;
t temp;
for(i=0;i<=n-2;i++)
{
min=i;
for(j=i+1;j<=n-1;j++){
if(arr[j]<arr[min]){
min=j;
}
}temp=arr[i];
arr[i]=arr[min];
arr[min]=temp;
}
cout<<"\nSorted list::\n";
for (i = 0; i < n; i++)
{
cout<<"\t"<<arr[i];
}}
int main()
{
int a[s],ch;
float b[s];
do
{
cout<<"\n1.int sort \n2.float sort \n3.Exit";
cout<<"\nEnter choice:: ";
cin>>ch;
switch (ch)
{
case 1:
{cout<<"\nEnter number of elements:: ";
cin>>n;
for ( i = 0; i < n; i++)
{
cout<<"\nEnter element:: ";
cin>>a[i];
}selection(a);
break;}
case 2:
{cout<<"\nEnter number of elements:: ";
cin>>n;
for ( i = 0; i < n; i++)
{
cout<<"\nEnter element:: ";
cin>>b[i];
}selection(b);
break;}
case 3:{
cout<<"\nThank you";
}
default:
break;
}
} while (ch!=3);
getch();
return 0;
}