-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork42.cpp
More file actions
59 lines (56 loc) · 1.07 KB
/
Copy pathwork42.cpp
File metadata and controls
59 lines (56 loc) · 1.07 KB
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
#include <iostream>
using namespace std;
template<typename T>
void Input(T arr[], int len)
{
for(int i = 0; i < len; i++)
{
cin >> arr[i];
}
}
template<typename T>
void Sort(T arr[], int len)
{
sort(arr, arr + len);
}
template<typename T>
void Output(T arr[], int len)
{
for(int i = 0; i < len; i++)
{
if(i > 0)
cout << ", ";
cout << arr[i];
}
cout << endl;
}
int main()
{
const int LEN = 5;
int type;
while (std::cin >> type)
{
switch (type)
{
case 0:
{
int a1[LEN];
Input<int>(a1, LEN); Sort<int>(a1, LEN); Output<int>(a1, LEN);
break;
}
case 1:
{
char a2[LEN];
Input(a2, LEN); Sort(a2, LEN); Output(a2, LEN);
break;
}
case 2:
{
double a3[LEN];
Input(a3, LEN); Sort(a3, LEN); Output(a3, LEN);
break;
}
}
}
return 0;
}