include iostream include cmath using namespace std template typename S

 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
#include <iostream>
#include <cmath>
using namespace std;
template <typename T>
T SearchMax(T * arr, int Size)
{
T max = arr[0];
T min = arr[0];
T temp;
for(int i = 1; i < Size; i++)
{
if(arr[i] > max)
max = arr[i];
if(arr[i] < min)
min = arr[i];
}
if(abs(min) > abs(max))
return min;
else
return max;
}
T PrintArr ( T * arr, int count)
{
cout << "Please, enter array : " << endl;
for(int i = 0; i < count; i++)
cin >> arr[i];
}
int main()
{
const int iSize = 5;
const int dSize = 5;
double arr[dSize];
int arr[iSize];
cout << "Maximum number by module : " << SearchMax<double>(arr, iSize) << SearchMax<int>(arr,dSize) << endl;
return 0;
}