C++程序不懂

作者在 2014-10-08 00:02:25 发布以下内容
#include<iostream>
using namespace std;
int main()
{
int max(int x,int y,int z);
double max(double x,double y,double z);
long max(long x,long y,long z);


int a,b,c,d;
cin>>a>>b>>c;
d=max(a,b,c);
cout<<"d_max="<<d<<endl;

double x,y,z,p;
cin>>x>>y>>z;
p=max(x,y,z);
cout<<"p_max="<<p<<endl;


long q,w,e,r;
cin>>q>>w>>e;
r=max(q,w,e);
cout<<"r_max="<<r<<endl;


return 0;
}


int max(int x,int y,int z)
{
if(x>y)
y=x;
if(z>y)
y=z;
return y;
}


double max(double x,double y,double z)
{
if(x>y)
y=x;
if(z>y)
y=z;
return y;
}


long max(long x,long y,long z)
{
if(x>y)
y=x;
if(z>y)
y=z;
return y;
}
为什么按照顺序输入整型、双精度、长整型的数可以输出最大值,但是不按照这个规矩就不行,就当输入一个双精度的数时,不能输出最大值。为什么会这样额啊
默认分类 | 阅读 628 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论