运行无误,输出结果为负数???????
#include<iostream>using namespace std;
int compare(int x,int y,int z)
{int max,a,b,c;
if(a>c)max=a;
else if(b>c)max=b;
else max=c;
return max;
}
double compare(double x,double y,double z)
{
double max,a,b,c;
if(a>c)max=a;
else if(b>c)max=b;
else max=c;
return max;
}
long compare( long int x, long int y,long int z)
{
long max,a,b,c;
if(a>c)max=a;
else if(b>c)max=b;
else max=c;
return max;
}
int main()
{ int a,b,c,d;
cin>>a>>b>>c;
d=compare(a,b,c);
cout<<"max="<<d;
double a1,b1,c1,d1;
cin>>a1>>b1>>c1;
d1= compare(a1,b1,c1);
cout<<"max="<<d1<<endl;
long a2,b2,c2,d2;
cin>>a2>>b2>>c2;
d2=compare(a2,b2,c2);
cout<<"max="<<d2<<endl;
}