您的位置:首页 > 编程语言 > C语言/C++

C++primer plus第六版课后编程练习答案8.5

2015-11-28 14:52 344 查看
#include<iostream>
#include<fstream>
#include<cstdlib>//
#include<string>
#include<cctype>

using namespace std;

template<typename T>
T max5(T t[]);

template<typename T>
T max5(T t[])
{
T temp=t[0];
for(int i=0;i<5;i++)
{
if(temp<t[i])
temp=t[i];
}
return temp;
}

void main()
{
int a[5]={1,3,5,2,4};
double d[5]={5,8.1,5.3,7.8,9.9};
cout<<max5(a)<<endl;
cout<<max5(d)<<endl;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: