Problem E: 函数---求三个数中的最大值
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 409 Solved: 258
[ Submit][ Status][ Web Board]
Description
编写函数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;
}
Input
三个整数
Output
这三个整数中的最大值
Sample Input
3 6 4
Sample Output
max=6
HINT
提交时,只需要提交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)
{
int max;
max=x;
max=(y>max)?y:max;
max=(z>max)?z:max;
return max;
}