C++primer plus第六版课后编程题答案8.5
来源:互联网 发布:河南的网络歌手 编辑:程序博客网 时间:2024/05/17 05:52
8.5
修改乱码----2015.01.20
#include <iostream>
using namespace std;
template <typename AnyType>
AnyType max5(AnyType arr[5])
{
//AnyType max=0;
AnyType max = arr[0];//这里应该是arr[0]
for (int i = 0; i<5; i++){
if (arr[i]>max)
max = arr[i];
}
return max;
};
void main()
{
int a[5] = { 10, 20, 50, 6, 33 };
double b[5] = { 5.2, 3.5, 6.7, 8.8, 4 };
cout << "the amax is " << max5(a) << endl;
cout << "the bmax is " << max5(b) << endl;
system("pause");
}
——————————————————————————————————————————————————————————————————————————————
以下为乱码,请忽略
</pre><pre code_snippet_id="285699" snippet_file_name="blog_20140410_1_8715504" name="code" class="cpp">#include <iostream>using namespace std;template <typename AnyType>AnyType max5(AnyType arr[5]){//AnyType max=0;
<span style="white-space:pre"></span><pre code_snippet_id="285699" snippet_file_name="blog_20140410_1_8715504" name="code" class="cpp"><span style="white-space:pre"></span>AnyType max=arr[0];//这里应该是arr[0]for(int i=0;i<5;i++){if(arr[i]>max)max=arr[i];}return max;};void main85(){int a[5]={10,20,50,6,33};double b[5]={5.2,3.5,6.7,8.8,4};cout<<"the amax is "<<max5(a)<<endl;cout<<"the bmax is "<<max5(b)<<endl;system("pause");}
0 0
- C++primer plus第六版课后编程题答案8.5
- C++primer plus第六版课后编程练习答案8.5
- C++primer plus第六版课后编程题答案 6.1
- C++primer plus第六版课后编程题答案 6.2
- C++primer plus第六版课后编程题答案 6.3
- C++primer plus第六版课后编程题答案 6.4
- C++primer plus第六版课后编程题答案 6.5
- C++primer plus第六版课后编程题答案 6.6
- C++primer plus第六版课后编程题答案 6.7
- C++primer plus第六版课后编程题答案 6.8
- C++primer plus第六版课后编程题答案 6.9
- C++primer plus第六版课后编程题答案7.1
- C++primer plus第六版课后编程题答案7.2
- C++primer plus第六版课后编程题答案7.3
- C++primer plus第六版课后编程题答案7.4
- C++primer plus第六版课后编程题答案7.5
- C++primer plus第六版课后编程题答案7.6
- C++primer plus第六版课后编程题答案 7.7
- java设计模式示例
- 大话数据结构之第一章数据结构绪论总结
- 编程之路能不能走下去
- Android下的动画处理
- sqlite 数据库 boolean类型的小小测试
- C++primer plus第六版课后编程题答案8.5
- 【Burnside引理】疫苗
- Java开发的10位牛人
- (转)十一种通用滤波算法
- 并发无连接服务器----设计思想
- 大话数据结构之第二章算法总结,重点知识,时间复杂度
- RIB表与FIB表、ARB表与FDB表的区别
- 《最后期限》读后感
- 黑马程序员_OC基础11_内存管理01