/*
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作 者:王颖
* 完成日期:2013 年 11 月 06 日
* 版 本 号:v1.0
*
* 输入描述: 无
* 问题描述:理解函数重载
* 程序输出:略
* 问题分析:略
* 算法设计:略
*/
#include <iostream>
using namespace std;
int max(int a,int b,int c) ;
double max(double a,double b,double c);
long max(long a,long b,long c);
int main()
{
int i1,i2,i3,i;
cin>>i1>>i2>>i3;
i=max(i1,i2,i3);
cout<<"i-max="<<i<<endl;
double d1,d2,d3,d;
cin>>d1>>d2>>d3;
d=max(d1,d2,d3);
cout<<"d-max="<<d<<endl;
long g1,g2,g3,g;
cin>>g1>>g2>>g3;
g=max(g1,g2,g3);
cout<<"g-max="<<g<<endl;
}
int max(int a,int b,int c)
{
if(b>a)a=b;
if(c>a)a=c;
return a;
}
double max(double a,double b,double c)
{
if(b>a)a=b;
if(c>a)a=c;
return a;
}
long max(long a,long b,long c)
{
if(b>a)a=b;
if(c>a)a=c;
return a;
}
理解函数的重载
最新推荐文章于 2019-06-22 21:43:32 发布