template<class Type> Type funcExp(Type list[], int size); int main() { int list
ID: 3627635 • Letter: T
Question
template<class Type>Type funcExp(Type list[], int size);
int main()
{
int list [10] = {5, 3, 2, 10, 4, 19, 45, 13, 61, 11};
string strList [] = {“One”,“Hello”,“Four”,“Three”,“How”,“Six”};
cout<<funcExp (list,10);
cout<<funcExp (strList,6)<<endl;
}
template<class Type>
Type funcExp(Type list[], int size)
{
int j;
Type x = list [0];
Type y = list [size – 1];
for (j = 1; j < (size -1 )/2; j++)
{
if (x < list [j])
x = list [j];
if (y > list[size – 1 –j])
y = list[size – 1 – j];
}
return x + y;
}
Explanation / Answer
See the comments below that begin with "//---". template Type funcExp(Type list[], int size); int main() { int list [10] = {5, 3, 2, 10, 4, 19, 45, 13, 61, 11}; string strList [] = {“One”,“Hello”,“Four”,“Three”,“How”,“Six”}; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.