题目描述
编写函数max,函数声明如下:
int max(int x,int y,int z); //求三个参数中的最大值的函数声明
在以下程序的基础上,添加max函数的定义,使程序能够正确执行。
提交时,只需要提交max函数的定义代码即可。
#include <iostream>
using namespace std;
int max(int x,int y,int z); //求三个参数中的最大值的函数声明
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<"max=";
cout<<max(a,b,c);
return 0;
}
输入
三个整数
输出
这三个整数中的最大值
样例输入
3 6 4
样例输出
max=6
提示
提交时,只需要提交max函数的定义代码即可。
#include <iostream>
using namespace std;
int max(int x,int y,int z); //求三个参数中的最大值的函数声明
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<"max=";
cout<<max(a,b,c);
return 0;
}
int max(int x,int y,int z){
if(x>=y && x>=z)
return x;
else if(y>=x && y>=z)
return y;
else
return z;
}