第十二周上机项目1 阅读程序(5)

来源:互联网 发布:兼职淘宝服装试衣模特 编辑:程序博客网 时间:2024/05/17 23:00
问题及代码:/ *                                        *Copyright  (c)  2014,烟台大学计算机学院   *All rights reserved .                        *文件名称:test .cpp                       *作    者:曹莉萍                        *完成日期:2014 年11月18日             *版 本 号: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;}
运行结果


0 0