D
david
I write a program which returns the maximum of three input integers.
both can run weil in the DEV-C++ , but I just wonder which one is
better,
and I also want to make it clear that if I use the function, I can
exert the
x,y,z in the funciton , then when apply the x,y,z in the main, there
is no error, but in my text book, some codes will use x,y,z in the
function then x1,x2,x3 in main, so what is difference between these
usage? please give me a help
thank you very much
/*this grogram find the maxmun of the three given numbers*/
int max(int,int,int);
int max(int a,int b)
{
if(a<b) return b;
else return a;
}
int max(int x, int y, int z)
{ if(z<x) return max(x,y);
else return max(y,z);
}
#include<iostream>
using namespace std;
int main()
{
int x,y,z;
cout<<"input three integers here"<<endl;
cin>>x>>y>>z;
cout<<max(x,y,z)<<endl;
return 0;
}
/*this grogram find the maxmun of the three given numbers*/
int max(int,int,int);
/*return the maxmun of two integers*/
int max(int a,int b)
{
if(a<b) return b;
else return a;
}
int max(int x, int y, int z)
{ if(z<x) return max(x,y);
else return max(y,z);
}
#include<iostream>
using namespace std;
int main()
{
int x1,x2,x3;
cout<<"input three integers here"<<endl;
cin>>x1>>x2>>x3;
cout<<max(x1,x2,x3)<<endl;
return 0;
}
/* with the using of reference,this grogram find the maxmun of the
three given numbers*/
int max(int& ,int&,int&);
/*return the maxmun of two integers*/
int max(int a,int b)
{
if(a<b) return b;
else return a;
}
int max(int& x, int& y, int& z)
{ if(z<x) return max(x,y);
else return max(y,z);
}
#include<iostream>
using namespace std;
int main()
{
int x,y,z;
cout<<"input three integers here"<<endl;
cin>>x>>y>>z;
cout<<max(x,y,z)<<endl;
return 0;
}
both can run weil in the DEV-C++ , but I just wonder which one is
better,
and I also want to make it clear that if I use the function, I can
exert the
x,y,z in the funciton , then when apply the x,y,z in the main, there
is no error, but in my text book, some codes will use x,y,z in the
function then x1,x2,x3 in main, so what is difference between these
usage? please give me a help
thank you very much
/*this grogram find the maxmun of the three given numbers*/
int max(int,int,int);
int max(int a,int b)
{
if(a<b) return b;
else return a;
}
int max(int x, int y, int z)
{ if(z<x) return max(x,y);
else return max(y,z);
}
#include<iostream>
using namespace std;
int main()
{
int x,y,z;
cout<<"input three integers here"<<endl;
cin>>x>>y>>z;
cout<<max(x,y,z)<<endl;
return 0;
}
/*this grogram find the maxmun of the three given numbers*/
int max(int,int,int);
/*return the maxmun of two integers*/
int max(int a,int b)
{
if(a<b) return b;
else return a;
}
int max(int x, int y, int z)
{ if(z<x) return max(x,y);
else return max(y,z);
}
#include<iostream>
using namespace std;
int main()
{
int x1,x2,x3;
cout<<"input three integers here"<<endl;
cin>>x1>>x2>>x3;
cout<<max(x1,x2,x3)<<endl;
return 0;
}
/* with the using of reference,this grogram find the maxmun of the
three given numbers*/
int max(int& ,int&,int&);
/*return the maxmun of two integers*/
int max(int a,int b)
{
if(a<b) return b;
else return a;
}
int max(int& x, int& y, int& z)
{ if(z<x) return max(x,y);
else return max(y,z);
}
#include<iostream>
using namespace std;
int main()
{
int x,y,z;
cout<<"input three integers here"<<endl;
cin>>x>>y>>z;
cout<<max(x,y,z)<<endl;
return 0;
}