求一个c++编程编写重载函数min可分别求取2个整数、3个整数、2个双精度数和3个双精度数的最大值
展开全部
int Min(int x,int y)
{
return (x<y)?x:y;
}
int Min(int x,int y,int z)
{
int t=(x<y)?x:y;
return (t<z)?t:z;
}
double Min(double x,double y)
{
return (x<y)?x:y;
}
double Min(double x,double y,double z)
{
double t=(x<y)?x:y;
return (t<z)?t:z;
}
void main()
{
cout<<Min(4,3)<<"\t"<<Min(9,7,8)<<endl;
cout<<Min(4.0,3.0)<<"\t"<<Min(9.0,7.0,8.0)<<endl;
getch();
}
{
return (x<y)?x:y;
}
int Min(int x,int y,int z)
{
int t=(x<y)?x:y;
return (t<z)?t:z;
}
double Min(double x,double y)
{
return (x<y)?x:y;
}
double Min(double x,double y,double z)
{
double t=(x<y)?x:y;
return (t<z)?t:z;
}
void main()
{
cout<<Min(4,3)<<"\t"<<Min(9,7,8)<<endl;
cout<<Min(4.0,3.0)<<"\t"<<Min(9.0,7.0,8.0)<<endl;
getch();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询