forked from thakursaurabh1998/cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathques14.cpp
57 lines (51 loc) · 853 Bytes
/
ques14.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
#include <iostream>
#include <vector>
using namespace std;
template <class T>
class object
{
vector <T> arr;
public:
void get(int n);
void sort();
void put();
};
template <class T>
void object<T>::get(int n)
{
T temp;
for(int i=0;i<n;i++)
{
cin >> temp;
arr.push_back(temp);
}
}
template <class T>
void object<T>::sort()
{
int n = arr.size();
T temp;
for(int i=0;i<n;i++)
for(int j=0;j<n-i-1;j++)
if(arr[j] > arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
template <class T>
void object<T>::put()
{
int n = arr.size();
for(int i=0;i<n;i++)
cout << arr.at(i) << endl;
}
int main()
{
object<float> i;
i.get(6);
i.sort();
i.put();
return 0;
}