第十二周项目-阅读程序

来源:互联网 发布:开机启动 linux 编辑:程序博客网 时间:2024/04/29 22:46
 */  * Copyright (c) 2014, 烟台大学计算机学院  * All rights reserved.  * 文件名称:test.cpp  * 作    者:梁璨  * 完成日期:2014年 11 月 15日  * 版 本 号:v1.0  *  * 问题描述:无;  * 输入描述:无;  * 程序输出:无; */#include <iostream>using namespace std;template<typename T>T max(T a,T b,T c){    if(b>a) a=b;    if(c>a) a=c;    return a;}int main(){    int i1=185,i2=-76,i3=567;    double d1=56.87,d2=90.23,d3=-3214.78;    long g1=67854,g2=-912456,g3=673456;    cout<<"i_max="<<max(i1,i2,i3)<<endl;    cout<<"f_max="<<max(d1,d2,d3)<<endl;    cout<<"g_max="<<max(g1,g2,g3)<<endl;    cout<<"c_max="<<max('1','a','A')<<endl;    return 0;}

运行结果:

心得:实际操作了用参数T代替每一种参数时调用。

0 0